Skip to content

Commit 1f60b28

Browse files
committed
put debug output behind a flag.
Every time you open a javascript file, it echoes the fact that it added node_modules to the path, which, when the package is operating as expected is mostly noise. This enhances the debug output to not only include the exact directories which are added to the `exec-path`, but also to only output when the debug flag, `add-node-modules-path-debug` is turned on.
1 parent 9ed240e commit 1f60b28

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

add-node-modules-path.el

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@
3131

3232
;;; Code:
3333

34+
;;;###autoload
35+
(defvar add-node-modules-path-debug nil
36+
"Enable verbose output when non nil.")
37+
3438
;;;###autoload
3539
(defun add-node-modules-path ()
40+
"Search the current buffer's parent directories for `node_modules/.bin`.
41+
If it's found, then add it to the `exec-path'."
3642
(let* ((root (locate-dominating-file
3743
(or (buffer-file-name) default-directory)
3844
"node_modules"))
@@ -42,8 +48,10 @@
4248
(progn
4349
(make-local-variable 'exec-path)
4450
(add-to-list 'exec-path path)
45-
(message "added node_modules to exec-path"))
46-
(message "node_modules not found"))))
51+
(when add-node-modules-path-debug
52+
(message (concat "added " path " to exec-path"))))
53+
(when add-node-modules-path-debug
54+
(message (concat "node_modules not found in " root))))))
4755

4856
(provide 'add-node-modules-path)
4957

0 commit comments

Comments
 (0)