Skip to content

Commit f31e69c

Browse files
benprewcodesuki
authored andcommitted
fix: does not work with buffers that have no backing file (#14)
1 parent b1b815f commit f31e69c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

add-node-modules-path.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ Traverse the directory structure up, until reaching the user's home directory,
4848
or hitting add-node-modules-max-depth.
4949
Any path found is added to the `exec-path'."
5050
(interactive)
51-
(let* ((file (or (buffer-file-name) default-directory))
51+
(let* ((default-dir (expand-file-name default-directory))
52+
(file (or (buffer-file-name) default-dir))
5253
(home (expand-file-name "~"))
5354
(iterations add-node-modules-max-depth)
54-
(root (directory-file-name (or (file-name-directory (buffer-file-name)) default-directory)))
55+
(root (directory-file-name (or (and (buffer-file-name) (file-name-directory (buffer-file-name))) default-dir)))
5556
(roots '()))
5657
(while (and root (> iterations 0))
5758
(setq iterations (1- iterations))

0 commit comments

Comments
 (0)