Last active
December 20, 2015 11:09
-
-
Save davidaurelio/6121184 to your computer and use it in GitHub Desktop.
bash helper function to make debugging node cli programs easier.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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