Skip to content

Commit

Permalink
Merge pull request #38 from joshbax189/fix/update-node-args
Browse files Browse the repository at this point in the history
Update args for repl.start()
  • Loading branch information
redguardtoo authored Nov 7, 2024
2 parents 103e574 + b99d805 commit 65a6972
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions js-comint.el
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,11 @@
(defvar js-comint-code-format
(concat
"process.stdout.columns = %d;"
"require('repl').start('%s', null, null, true, false, "
"require('repl')['REPL_MODE_' + '%s'.toUpperCase()])"))
"require('repl').start({
\"prompt\": '%s',
\"ignoreUndefined\": true,
\"preview\": true
})"))

(defvar js-nvm-current-version nil
"Current version of node for js-comint.
Expand Down Expand Up @@ -308,9 +311,8 @@ Create a new Javascript REPL process."
js-comint-module-paths)))
(all-paths-list (seq-remove 'string-empty-p all-paths-list))
(local-node-path (string-join all-paths-list (js-comint--path-sep)))
(repl-mode (or (getenv "NODE_REPL_MODE") "magic"))
(js-comint-code (format js-comint-code-format
(window-width) js-comint-prompt repl-mode)))
(window-width) js-comint-prompt)))
(with-environment-variables (("NODE_NO_READLINE" "1")
("NODE_PATH" local-node-path))
(pop-to-buffer
Expand Down
6 changes: 6 additions & 0 deletions test-js-comint.el
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,9 @@ reduce((prev, curr) => prev + curr, 0);" "^9$")))
(setenv "NODE_PATH" original-env)
(fset 'js-comint--suggest-module-path original-suggest)
(js-comint-test-exit-comint))))

(ert-deftest js-comint/test-strict-mode ()
"When NODE_REPL_MODE=strict should use strict mode."
(with-environment-variables (("NODE_REPL_MODE" "strict"))
;; global variables are not allowed in strict mode
(js-comint-test-output-matches "foo = 5;" "Uncaught ReferenceError.*")))

0 comments on commit 65a6972

Please sign in to comment.