mocha.el icon indicating copy to clipboard operation
mocha.el copied to clipboard

Use nvm.el

Open scottaj opened this issue 9 years ago • 4 comments

scottaj avatar Jan 24 '16 01:01 scottaj

This is pretty low priority. The current technique of just specifying which node to use works really well.

scottaj avatar Feb 03 '16 18:02 scottaj

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 avatar Sep 06 '17 14:09 dcluna

@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.

Fuco1 avatar Oct 18 '17 09:10 Fuco1

If you're using nvm.el, once this PR is merged, you can add something like this to your init file:

(add-hook 'js2-mode-hook 'nvm-use-for-buffer)

Then, leaving mocha-which-node as node will work if you've defined an .nvmrc file, without having to mess around with dir locals (particularly eval)

felipeochoa avatar Dec 03 '17 17:12 felipeochoa