mocha.el
mocha.el copied to clipboard
Use nvm.el
This is pretty low priority. The current technique of just specifying which node to use works really well.
In case someone needs a quick fix for this, I have something like the following in my .dir-locals.el:
((js2-mode . ((eval . (progn
(setq mocha-which-node
(if (boundp 'nvm-current-version)
(concat (cadr nvm-current-version) "/bin/node")
(concat (getenv "HOME") "/.nvm/versions/node/v" (s-chomp (f-read-text (concat default-directory ".nvmrc"))) "/bin/node" )))
))
;; other vars here...
)))
Notice that I'm relying on this file being in the root of the project, the same place where .nvmrc is located.
@dcluna I've replaced default-directory with (locate-dominating-file default-directory "package.json") so it works from nested directories as well. I like the solution, at least for a while.