File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 36
36
" Enable verbose output when non nil."
37
37
:type 'boolean )
38
38
39
+ ;;;### autoload
40
+ (defcustom add-node-modules-max-depth 20
41
+ " Max depth to look for node_modules."
42
+ :type 'integer )
43
+
39
44
;;;### autoload
40
45
(defun add-node-modules-path ()
41
46
" Search the current buffer's parent directories for `node_modules/.bin`.
42
- Traverse the directory structure up, until reaching the user's home directory.
47
+ Traverse the directory structure up, until reaching the user's home directory,
48
+ or hitting add-node-modules-max-depth.
43
49
Any path found is added to the `exec-path' ."
44
50
(interactive )
45
51
(let* ((file (or (buffer-file-name ) default-directory))
46
- (path (locate-dominating-file file " node_modules" ))
47
52
(home (expand-file-name " ~" ))
48
- (root (and path (expand-file-name path)))
53
+ (iterations add-node-modules-max-depth)
54
+ (root (directory-file-name (or (file-name-directory (buffer-file-name )) default-directory)))
49
55
(roots '()))
50
- (while root
56
+ (while (and root (> iterations 0 ))
57
+ (setq iterations (1- iterations))
51
58
(let ((bindir (expand-file-name " node_modules/.bin/" root)))
52
59
(when (file-directory-p bindir)
53
60
(add-to-list 'roots bindir)))
You can’t perform that action at this time.
0 commit comments