-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Description
Is your feature request related to a problem? Please describe.
Yes, I've a node.js CLI app which I'd like to enable debugging off via setting DEBUG=my-cli before running my program; As it uses #! and other things, I can't set the flags to the node executable.
I have discovered I can start the inspector programmatically, but not in --inspect-brk mode, so my program runs and exits before I can connect to the inspector.
if (process.env.DEBUG && process.env.DEBUG.includes("my-cli")) {
process.kill(process.pid, "SIGUSR1");
}
Describe the solution you'd like
Ideally, it'd be great to have some sort of API like: Inspector.start() or Inspector.start({ break: true }) to start the inspector and also make it break-point immediately, even though no clients are yet connected to the inspector.
Describe alternatives you've considered
There's not really other alternatives, other than doing:
node --inspect --inspect-brk ./bin/run ...
I don't think I can do:
node --inspect --inspect-brk my-cli
Which isn't ideal, as it's leaking internals of how my package works to consumers, whereas DEBUG=my-cli my-cli doesn't