Skip to content

Commit f492680

Browse files
authored
Chore: Support running .js and .ts files (#35)
* Support running .js and .ts files * remove comment
1 parent 167703b commit f492680

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ai-code-file.el

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ If the clipboard contains a directory path, open it directly in dired in another
101101

102102
;;;###autoload
103103
(defun ai-code-run-current-file ()
104-
"Generate command to run current script file (.py or .sh).
104+
"Generate command to run current script file (.py, .js, .ts, or .sh).
105105
Let user modify the command before running it in a compile buffer.
106106
Maintains a dedicated history list for this command."
107107
(interactive)
@@ -114,16 +114,20 @@ Maintains a dedicated history list for this command."
114114
;; Check if current file is in the last run command
115115
((and last-command file-name (string-match-p (regexp-quote file-name) last-command))
116116
last-command)
117-
;; Generate default command based on file extension
117+
;; Generate default command based on file extension
118118
((string= file-ext "py")
119119
(format "python %s" file-name))
120+
((string= file-ext "js")
121+
(format "node %s" file-name))
122+
((string= file-ext "ts")
123+
(format "ts-node %s" file-name))
120124
((string= file-ext "sh")
121125
(format "bash %s" file-name))
122126
(t nil))))
123127
(unless current-file
124128
(user-error "Current buffer is not visiting a file"))
125129
(unless default-command
126-
(user-error "Current file is not a .py or .sh file"))
130+
(user-error "Current file is not a .py, .js, .ts, or .sh file"))
127131
(let ((command (read-string (format "Run command for %s: " file-name)
128132
default-command
129133
'ai-code-run-file-history)))

0 commit comments

Comments
 (0)