Skip to content

Instantly share code, notes, and snippets.

@davidaurelio
Last active December 20, 2015 11:09
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save davidaurelio/6121184 to your computer and use it in GitHub Desktop.
bash helper function to make debugging node cli programs easier.
node-debug () {
PROGRAM="$(which $1)" # make sure we get an absolute path for programs in PATH
shift # remove the original program argument
set -- "$PROGRAM" "$@" # prepend the program path
node --debug-brk $@ & # start node in paused debug mode, send to background
node-inspector # start node inspector
kill %% # kill the background task (if still running)
}
# if you run your program like this ...
node path/to/program -some parameters --go here
# ... just add '-debug'
node-debug path/to/program -some parameters --go here
# if your program is in PATH ...
program -some parameters --go here
# just prefix with 'node-debug'
node-debug program -some parameters --go here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment