|
91 | 91 | (defvar ts-comint-buffer nil
|
92 | 92 | "Name of the inferior Typescript buffer.")
|
93 | 93 |
|
94 |
| -(defvar ts-prompt-regexp "^\\(?:> \\)" |
95 |
| - "Prompt for `run-ts'.") |
96 | 94 |
|
97 |
| - |
98 |
| -(defun ts--is-nodejs () |
99 |
| - (string= "node" |
100 |
| - (substring-no-properties ts-comint-program-command -4 nil))) |
101 |
| - |
102 |
| -(defun ts--guess-load-file-cmd (filename) |
103 |
| - (let ((cmd (concat "require(\"" filename "\")\n"))) |
104 |
| - (when (not (ts--is-nodejs)) |
105 |
| - (setq cmd (concat "load(\"" filename "\")\n"))) |
106 |
| - cmd |
107 |
| - )) |
| 95 | +(defun ts--get-load-file-cmd (filename) |
| 96 | + "Generate a Typescript import-statement for `FILENAME'." |
| 97 | + (concat "import * as " |
| 98 | + (file-name-base filename) |
| 99 | + " from \"" |
| 100 | + (file-name-base filename) |
| 101 | + "\"\n")) |
108 | 102 |
|
109 | 103 | ;;;###autoload
|
110 | 104 | (defun run-ts (cmd &optional dont-switch-p)
|
@@ -213,15 +207,15 @@ prevent switching to the new buffer once created."
|
213 | 207 | (interactive "f")
|
214 | 208 | (let ((filename (expand-file-name filename)))
|
215 | 209 | (run-ts ts-comint-program-command t)
|
216 |
| - (comint-send-string ts-comint-buffer (ts--guess-load-file-cmd filename)))) |
| 210 | + (comint-send-string ts-comint-buffer (ts--get-load-file-cmd filename)))) |
217 | 211 |
|
218 | 212 | ;;;###autoload
|
219 | 213 | (defun ts-load-file-and-go (filename)
|
220 | 214 | "Load file `FILENAME' in the Typescript interpreter."
|
221 | 215 | (interactive "f")
|
222 | 216 | (let ((filename (expand-file-name filename)))
|
223 | 217 | (run-ts ts-comint-program-command t)
|
224 |
| - (comint-send-string ts-comint-buffer (ts--guess-load-file-cmd filename)) |
| 218 | + (comint-send-string ts-comint-buffer (ts--get-load-file-cmd filename)) |
225 | 219 | (switch-to-ts ts-comint-buffer)))
|
226 | 220 |
|
227 | 221 | ;;;###autoload
|
|
0 commit comments