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 3636 " Enable verbose output when non nil."
3737 :type 'boolean )
3838
39+ ;;;### autoload
40+ (defcustom add-node-modules-max-depth 20
41+ " Max depth to look for node_modules."
42+ :type 'integer )
43+
3944;;;### autoload
4045(defun add-node-modules-path ()
4146 " 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.
4349Any path found is added to the `exec-path' ."
4450 (interactive )
4551 (let* ((file (or (buffer-file-name ) default-directory))
46- (path (locate-dominating-file file " node_modules" ))
4752 (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)))
4955 (roots '()))
50- (while root
56+ (while (and root (> iterations 0 ))
57+ (setq iterations (1- iterations))
5158 (let ((bindir (expand-file-name " node_modules/.bin/" root)))
5259 (when (file-directory-p bindir)
5360 (add-to-list 'roots bindir)))
You can’t perform that action at this time.
0 commit comments