Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/lexical binding #37

Merged
merged 20 commits into from
Oct 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e01b753
Enable lexical binding
joshbax189 Oct 15, 2024
cc6a360
Ignore string arg to js-comint-filter-output
joshbax189 Oct 17, 2024
ed7e77a
Lint and simplify js-comint-repl
joshbax189 Oct 17, 2024
d9088c3
Add lexical-binding and requires to test
joshbax189 Oct 16, 2024
ceeb9eb
Bug: js-comint--suggest-module-path should be nil if no node_modules
joshbax189 Oct 17, 2024
addff71
Use temporary local env vars when calling comint
joshbax189 Oct 17, 2024
3d879f5
Remove unused js-comint-setup-module-paths
joshbax189 Oct 17, 2024
2eceaf3
Depend on emacs 28.1 to use with-environment-variables
joshbax189 Oct 17, 2024
18ab673
Tidy argument handling for js-comint-repl
joshbax189 Oct 17, 2024
e83eb27
Add missing customization types to fix compiler warnings
joshbax189 Oct 17, 2024
2058be8
Add unit tests for js-comint-start-or-switch-to-repl
joshbax189 Oct 17, 2024
dd6c117
Simplify js-comint--suggest-module-path
joshbax189 Oct 17, 2024
951131c
Have js-comint-start-or-switch-to-repl check local node_modules
joshbax189 Oct 17, 2024
be24e8e
Fix failing test
joshbax189 Oct 18, 2024
7ceec3d
Factor out process exit logic in tests
joshbax189 Oct 18, 2024
8f05c1b
Add declares for nvm functions.
joshbax189 Oct 18, 2024
7fbcb4b
Move (require 'nvm) into select-node-version, tidy logic
joshbax189 Oct 18, 2024
1c3b1ab
Message when changing cmd while nvm is set
joshbax189 Oct 18, 2024
6eaa359
Do not include empty strings in path
joshbax189 Oct 18, 2024
4353fe2
Switch buffers in start-or-switch-to-buffer
joshbax189 Oct 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify js-comint--suggest-module-path
read-directory-name defaults to default-directory if nil
and expand-file-name produces output equivalent to file-truename.
joshbax189 committed Oct 17, 2024
commit dd6c11718310a84ec965c79b73f3f7e90013133d
14 changes: 5 additions & 9 deletions js-comint.el
Original file line number Diff line number Diff line change
@@ -193,7 +193,7 @@ Return a string representing the node version."
(defun js-comint--suggest-module-path ()
"Path to node_modules in parent dirs, or nil if none exists."
(when-let ((dir (locate-dominating-file default-directory "node_modules")))
(concat (file-name-as-directory dir) "node_modules")))
(expand-file-name "node_modules" dir)))

(defun js-comint-get-process ()
"Get repl process."
@@ -205,8 +205,7 @@ Return a string representing the node version."
"Add a directory to `js-comint-module-paths'."
(interactive)
(let ((dir (read-directory-name "Module path:"
(or (js-comint--suggest-module-path)
default-directory))))
(js-comint--suggest-module-path))))
(when dir
(add-to-list 'js-comint-module-paths (file-truename dir))
(message "\"%s\" added to `js-comint-module-paths'" dir))))
@@ -341,12 +340,9 @@ set CMD."
(setq js-comint-program-arguments (split-string cmd))
(setq js-comint-program-command (pop js-comint-program-arguments)))

;; set NODE_PATH automatically
(if-let ((module-path (and js-comint-set-env-when-startup
(js-comint--suggest-module-path))))
(js-comint-start-or-switch-to-repl (file-truename module-path))
;; else
(js-comint-start-or-switch-to-repl)))
;; set NODE_PATH if js-comint-set-env-when-startup is true
(js-comint-start-or-switch-to-repl (and js-comint-set-env-when-startup
(js-comint--suggest-module-path))))

(defalias 'run-js 'js-comint-repl)