Browse Source

Make sure the exec path is setup correctly for node processes

Fix #59
workspaces
Nicolas Petton 5 years ago
parent
commit
af23fc45ae
Signed by: nico GPG Key ID: 233587A47C207910
4 changed files with 25 additions and 1 deletions
  1. +1
    -0
      Cask
  2. +13
    -0
      indium-nodejs.el
  3. +1
    -1
      indium.el
  4. +10
    -0
      test/unit/indium-nodejs-test.el

+ 1
- 0
Cask View File

@ -6,6 +6,7 @@
(depends-on "websocket")
(depends-on "company")
(depends-on "magit-popup")
(depends-on "exec-path-from-shell")
(development
(depends-on "undercover")


+ 13
- 0
indium-nodejs.el View File

@ -41,12 +41,16 @@
(require 'json)
(require 'map)
(require 'seq)
(require 'exec-path-from-shell)
(require 'indium-webkit)
(defvar indium-nodejs-commands-history nil
"Nodejs commands history.")
(defvar indium-exec-path-setup nil
"Whether the exec path has been set up.")
(defun indium-run-node (command)
"Start a NodeJS process.
Execute COMMAND, adding the `--inspect' and `--debug-brk' flags.
@ -54,6 +58,7 @@ When the process is ready, open an Indium connection on it."
(interactive (list (read-shell-command "Node command: "
(or (car indium-nodejs-commands-history) "node ")
'indium-nodejs-commands-history)))
(indium--setup-exec-path)
(let ((process (make-process :name "indium-nodejs-process"
:buffer "*node process*"
:filter #'indium-nodejs--process-filter
@ -106,6 +111,14 @@ socket URL to connect to."
(when-let ((path (match-string 1 output)))
(indium-nodejs--connect "127.0.0.1" "9229" path))))
(defun indium--setup-exec-path ()
"Setup the exec path using `exec-path-from-shell'.
This ensures that the nodejs binary used by Emacs will be the
same as the one from the user's shell."
(unless indium-exec-path-setup
(exec-path-from-shell-initialize)
(setq indium-exec-path-setup t)))
(provide 'indium-nodejs)
;;; indium-nodejs.el ends here

+ 1
- 1
indium.el View File

@ -6,7 +6,7 @@
;; URL: https://github.com/NicolasPetton/indium
;; Keywords: tools, javascript
;; Version: 0.5.0
;; Package-Requires: ((emacs "25") (seq "2.16") (js2-mode "20140114") (company "0.9.0") (websocket "1.6") (magit-popup "2.10.3"))
;; Package-Requires: ((emacs "25") (seq "2.16") (js2-mode "20140114") (company "0.9.0") (websocket "1.6") (magit-popup "2.10.3") (exec-path-from-shell "1.11"))
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by


+ 10
- 0
test/unit/indium-nodejs-test.el View File

@ -52,5 +52,15 @@
(expect #'indium-nodejs--connect
:to-have-been-called-with "127.0.0.1" "9229" "43c07a90-1aed-4753-961d-1d449b21e84f"))))
(describe "Setting up the exec path"
(it "should setup the exec path before starting a node process"
(spy-on 'make-process)
(spy-on 'switch-to-buffer)
(spy-on 'process-buffer)
(spy-on 'indium--setup-exec-path)
(indium-run-node "node foo")
(expect #'indium--setup-exec-path :to-have-been-called)))
(provide 'indium-nodejs-test)
;;; indium-nodejs-test.el ends here

Loading…
Cancel
Save