* fix: package.main with -- arguments
Fixes#1758
The combination of using a package.main (which sets the script
position to index zero) and using the -- stop slurp meant that
the arguments had the script appended to the end instead of
prepended to the start. The net result meant that when the script
was forked, it would drop the first user arg.
See diff for details of the fix - a simple check against null.
* fix: protect against missing opts
Fixes#1638
This also simplifies the shutdown process by sending the kill signal to
the sub-process - thus ensuring we don't get the weird "User defined
singal" from the shell.
This commit also includes a test to ensure this doesn't happen again.
Fixes#1633
Multiple parts but all localised to run.js:
- Refactor the kill logic to be simpler
- Consistently use pstree to determine sub process list
- Pipe stderr through nodemon to squash `sh -c` error warning
Bug was caused by waiting on multiple sub processes and if they all
ended the logic would only subtract one from the count list (rather
than the total number).
I've refactored the code so that it doesn't use the `kill -0 <pid>` as
this was a little confusing to read (it's effectively a no op) and
switched to using pstree to test if any sub processes are still running.
The logic for killing the processes has also been refactored to
simplify. Before it would fork the logic based on whether `ps` existed
on the system.
Now it uses the same logic with the exception of the kill signal sent -
when `ps` isn't on the system, we have to send numeric signals (I can't
remember how I found that out, but I do remember it was a painful
process!).
The last part required due to a side effect of the refactor on kill:
when a kill signial is sent to `sh -c` the shell prints a warning.
Details on how to replicate: https://git.io/Je6d0
To squash this, I track if the process is about to be killed (by
flagging the sub process right before the kill function call) and if
there's an error whilst shutdown is in effect, the error is only printed
to nodemon's detailed output (using nodemon -V).
Fixes node 11's `rs` support. Somehow required that the `process.stdin` to be disconnected from the child before the stream is resumed (whereas previously it seemed that it would automatically happen…possibly a node 11 bug).
Fixes#1493
Only exit after code 2 if it happened quickly; improve messaging (recommend `||exit 1`)
If nodemon exits _quickly_ on code 2, then it'll bail and warn. If it's after ~500ms, then it assumes that the sub-process intentionally used exit 2 (like mocha or stylelint), it won't bail and treat it as a failure (like a crash).
Props to @joeytwiddle
Fixes#496Fixes#627
This change takes code from npm's cli to change the way the arguments
passed to nodemon are interpreted.
Removes path.normalize and replaces with windowsVerbatimArguments
Fixes#1236
Originally used ps-tree which relied on `ps` on *nix. But if the system
didn't have `ps` at all, we'd try to kill the child process, but alas
this would not always work, as we're spawning `sh` and _then_ node, so
the kill would only kill the `sh` process, and not the running node
process.
The new @remy/pstree lib sniffs for `ps` and defers to ps-tree,
otherwise it will walk /proc and map the PPID to the child process
allowing nodemon to fully clean up.
* fix: pass through execArgs from config
Also updating some deps and linting tweaks
* chore: add message on postinstall
Lost funds from gratipay and codesponsor 😢
I'm using nodemon in a docker container with a restart policy configured to restart the container in case it crashes. If the app crashes, nodemon exits with code 0 and docker assumes it was a graceful exit, so it does not restart my container. I don't see the harm in changing the exit code here to reflect an unexpected termination, given that this path is only exercised in the event of a crash.
- If the user configured a *nix compatible npm script where the path contained a forward slash, that failed under windows, since cmd.exe treated that as a command line argument.
- The quote handling was not 100% correct under windows, the whole path needs to be quoted, not just the segments it is also modified.