Browse Source

GH Fix issue #194

* indium-nodejs.el (indium-launch-nodejs): Use the specified port if provided in
  the configuration.
* test/unit/indium-nodejs-test.el: Add a regression test.
drone
Nicolas Petton 3 years ago
parent
commit
8872448676
No known key found for this signature in database GPG Key ID: E8BCD7866AFCF978
2 changed files with 18 additions and 7 deletions
  1. +10
    -5
      indium-nodejs.el
  2. +8
    -2
      test/unit/indium-nodejs-test.el

+ 10
- 5
indium-nodejs.el View File

@ -57,18 +57,23 @@ execution at the first statement."
shell-command-switch
(indium-nodejs--command-with-flags
.command
.inspect-brk)))))
.inspect-brk
.port)))))
(switch-to-buffer (process-buffer process)))))
(defun indium-nodejs--command-with-flags (command inspect-brk)
(defun indium-nodejs--command-with-flags (command inspect-brk &optional port)
"Return COMMAND with flags to start the V8 inspector.
If INSPECT-BRK is nil, use the `--inspect', use the
`--inspect-brk' flag otherwise."
(let ((inspect-flag (if (eq inspect-brk t) "--inspect-brk" "--inspect")))
`--inspect-brk' flag otherwise.
If PORT is non-nil, start the debugging process on that port,
otherwise use Node's default port (9229)."
(let ((inspect-flag (if (eq inspect-brk t) " --inspect-brk" " --inspect"))
(inspect-port-flag (if port (format " --inspect-port=%s" port) "")))
(if (string-match "\\<node\\>" command)
(replace-match (concat "node " inspect-flag) nil nil command)
(replace-match (format "node%s%s" inspect-flag inspect-port-flag) nil nil command)
(user-error "Invalid command specified"))))
(defun indium-nodejs--process-filter-function (conf)


+ 8
- 2
test/unit/indium-nodejs-test.el View File

@ -40,7 +40,7 @@
(indium-launch-nodejs '((command . "node index.js")
(inspect-brk . t))))
(expect #'indium-nodejs--command-with-flags
:to-have-been-called-with "node index.js" t))
:to-have-been-called-with "node index.js" t nil))
(it "should append extra flags"
(expect (indium-nodejs--command-with-flags "node foo" nil)
@ -49,7 +49,13 @@
:to-equal "node --inspect-brk foo")
;; Regression for GitHub issue #150
(expect (indium-nodejs--command-with-flags "ENV_VAR=\"VAL\" node foo" t)
:to-equal "ENV_VAR=\"VAL\" node --inspect-brk foo")))
:to-equal "ENV_VAR=\"VAL\" node --inspect-brk foo"))
(it "should append extra the debugging port flag"
(expect (indium-nodejs--command-with-flags "node foo" nil 2000)
:to-equal "node --inspect --inspect-port=2000 foo")
(expect (indium-nodejs--command-with-flags "node foo" t 2000)
:to-equal "node --inspect-brk --inspect-port=2000 foo")))
(provide 'indium-nodejs-test)
;;; indium-nodejs-test.el ends here

Loading…
Cancel
Save