Add node_modules/.bin to exec-path regardless #798

Before, this was conditional to the directory's existence. Add it
anyway, in case the folder is created while the buffer is open.

This may cause a problem is the project root changes while the buffer is
open, but for that case there's M-x doom/reload-project.
This commit is contained in:
Henrik Lissner 2018-08-11 01:55:38 +02:00
parent ddf107a507
commit 12c5490a39
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -86,19 +86,15 @@ Run this for any buffer you want to skewer."
;;;###autoload
(defun +javascript|add-node-modules-path ()
"Search the current buffer's parent directories for `node_modules/.bin`.
If it's found, then add it to the `exec-path'."
(if-let* ((root (locate-dominating-file
(or (buffer-file-name) default-directory)
"node_modules"))
(path (expand-file-name "node_modules/.bin/" root)))
(progn
(make-local-variable 'exec-path)
(cl-pushnew path exec-path :test #'string=)
(when doom-debug-mode
(message "Added %s to exec-path" path)))
(when doom-debug-mode
(message "node_modules not found in %s" root))))
"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 ()