Add add-node-modules-path package to lang/javascript

And use it on json-mode.
This commit is contained in:
Henrik Lissner 2020-04-23 17:04:31 -04:00
parent 346a90c95d
commit 17dd1c6527
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 3 additions and 13 deletions

View file

@ -83,18 +83,6 @@ Run this for any buffer you want to skewer."
;;
;; Hooks
;;;###autoload
(defun +javascript-add-node-modules-path-h ()
"Add current project's `node_modules/.bin` to `exec-path', so js tools
prioritize project-local packages over global ones."
(make-local-variable 'exec-path)
(cl-pushnew (expand-file-name "node_modules/.bin/"
(or (locate-dominating-file
(or (buffer-file-name) default-directory)
"node_modules")
(doom-project-root)))
exec-path :test #'string=))
;;;###autoload
(defun +javascript-cleanup-tide-processes-h ()
"Clean up dangling tsserver processes if there are no more buffers with

View file

@ -292,10 +292,11 @@ to tide."
web-mode
markdown-mode
js-mode
json-mode
typescript-mode
solidity-mode)
:when (locate-dominating-file default-directory "package.json")
:add-hooks '(+javascript-add-node-modules-path-h npm-mode))
:add-hooks '(add-node-modules-path npm-mode))
(def-project-mode! +javascript-gulp-mode
:when (locate-dominating-file default-directory "gulpfile.js"))

View file

@ -11,6 +11,7 @@
(package! eslintd-fix :pin "0c431141be")
(package! js2-refactor :pin "d4c40b5fc8")
(package! npm-mode :pin "3ee7c0bad5")
(package! add-node-modules-path :pin "f31e69ccb6")
;; Eval
(package! nodejs-repl :pin "6fad7d764f")