130 Commits

Author SHA1 Message Date
Stijn Herreman
e26aaa97d9 fix: support windows by using path.delimiter 2022-04-29 11:08:31 +01:00
mohamed salah
61e7abd730 fix: add windows signals SIGUSR2 & SIGUSR1 to terminate the process (#1938)
Authored-by: mohamed <mohamedsalah.software@gmail.com>

Fixes: #1903, #1915, #1936, #1937, #1882, #1893
2021-10-19 15:29:36 +01:00
Remy Sharp
90e7a3e1e2 fix: bump update-notifier
fixes: #1919
2021-09-23 10:41:14 +01:00
Remy Sharp
f523d0ea49 fix: ensure numerical OS version check 2021-07-09 17:19:02 +01:00
Remy Sharp
6c6cb65317 fix: windows 8 doesn't support windows-kill
Fixes #1876
2021-07-08 15:48:16 +01:00
Remy Sharp
3242215ec4 fix: allow windows users to install globally again (#1874)
Fixes: #1872
2021-06-30 13:57:24 +01:00
Finn Kumkar
500c1b06e8 fix: add support for SIGINT on Windows (fixes issue #1720) (#1853)
Smashing work by @countzero ❤️
2021-06-24 22:02:46 +01:00
Chakradhar Palaparthi
7e00a30d31 fix: runOnChangeOnly=true
Fxies issue #1742: corrected run.js, run.test.js, watch.js for the use case runOnChangeOnly=true (#1751)
2020-10-04 20:37:50 +01:00
Remy Sharp
2967726673 fix: package.main with -- arguments (#1773)
* 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
2020-10-04 16:44:26 +01:00
Remy Sharp
496c3353c4 chore: undo change to spawn code 2019-12-04 16:09:33 +00:00
Remy Sharp
47dfb8be3f fix: pipe stderr correctly
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.
2019-12-04 15:07:27 +00:00
Remy Sharp
ed91703f08 fix: ubuntu loop waiting for sub processes
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).
2019-11-22 13:01:31 +00:00
Marcel Kottmann
0e6ba3ce6d fix: wait for all subprocesses to terminate (fixes issue #1476) 2019-11-20 15:16:55 +00:00
Remy Sharp
5124ae9528 Merge branch 'master' of github.com:remy/nodemon
* 'master' of github.com:remy/nodemon:
  chore: adding funding file
  chore: update stalebot
  feat: add message event
  fix: disable fork only if string starts with dash
  feat: add TypeScript to default execPath (#1552)
  fix: Quote zero-length strings in arguments (#1551)
2019-05-25 19:26:24 +01:00
Remy Sharp
13afac22a3 fix: ensure signal is sent to exit event 2019-05-08 15:01:50 +01:00
Emily Marigold Klassen
20ccb623c4 feat: add message event
add event to listen to messages coming from the child's ipc events, partially implementing #1519
2019-05-01 08:05:47 +01:00
Emily Marigold Klassen
886527f1f0 fix: disable fork only if string starts with dash
fixes #1554
2019-05-01 08:05:18 +01:00
Remy Sharp
dd0b96a943 fix: rs in node@11 (#1493)
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
2018-12-14 17:43:18 +00:00
Remy Sharp
21e052eddf fix: upgrade pstree to remove vulnerability
Fixes #1463
Fixes #1469
Fixes #1464 

Completely removes the old method of `pstree[.remy]` and drops the event-stream vuln at the same time.
2018-11-27 08:45:11 +00:00
Aaron Jensen
521eb1e49d fix: restart on change for non-default signals (#1409) (#1430)
Fixes #1409
2018-11-05 11:23:14 +00:00
Paul "Joey" Clark
11ef298303 fix: smarter handling of exit code 2
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 #496 
Fixes #627
2018-07-17 19:23:25 +01:00
Remy Sharp
25a181351f fix: send proper quit signal on ctrl-c (#1387)
Fixes #1386

Also sends the correct signal codes on exit - so instead of $?=1 on
ctrl-c, you'll see $?=130 as per http://tldp.org/LDP/abs/html/exitcodes.html
2018-07-11 12:51:35 +01:00
Remy Sharp
9bbc219fd5 fix: only hook SIGINT on boot - not at require
Fixes #1326
2018-05-05 20:16:37 +01:00
Remy Sharp
85ed19d69a fix: throwing exeception on run
Fixes #1276

Due to const being used.
2018-02-27 17:34:28 +00:00
Remy Sharp
7fb365d0cc feat: try to resolve exec in node_modules/.bin (#1275)
Fixes #1268
2018-02-27 16:44:14 +00:00
Remy Sharp
7ffd5454ed fix: windows exec resolution (#1274)
Fixes #1251
2018-02-27 16:43:20 +00:00
Remy Sharp
88954455be fix: make watch & ignore relative (#1253)
* docs: add sponsors

[skip ci]

* fix: make watch & ignore relative

Fixes #1246

* fix: relative parent watching and ignore

* chore: lint

* test: fix bail on options
2018-02-15 21:57:47 +00:00
Remy Sharp
5e88b04eaa feat: add support for --spawn (#1249)
* docs: add sponsors

[skip ci]

* feat: add support for `--spawn`

Fixes #1245

* docs: remove "simply"
2018-02-15 21:57:30 +00:00
Remy Sharp
33fa6f4970 fix: wrongly normalizing slashes in windows
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
2018-02-01 22:47:56 +00:00
Remy Sharp
4cfd0b9cf8 chore: fix lint warning 2018-02-01 22:47:41 +00:00
Remy Sharp
79e61f00e7 fix: sniff for child.stdout before using it
This fixes node@6.0.0, but it's a hack, so I'm going to emit a message
saying that non-LTS is not supported.
2018-02-01 22:47:41 +00:00
Remy Sharp
e90f15aa8a fix: node < 6.4.0 causing crash on 'rs' trigger
* fix: node < 6.4.0 can't connect to stdin
* fix: child stdio when spawn is similar to fork

Fixes #1218
2018-01-09 13:18:08 +00:00
Remy Sharp
c121187611 refactor: indexOf > includes (in node4) 2018-01-08 12:33:51 +00:00
Remy Sharp
6e7ce4bbe2 fix: swallow child.stdin err
This is a weird case where stdin isn't fully connected and throws in
ubuntu 16.04 (replicated in a Docker image).

Fixes #1195
2017-12-31 19:47:16 +00:00
Remy Sharp
0d9a89241c fix: don't use fork with node inspect
Fixes: #1191
2017-12-29 11:07:04 +00:00
Remy Sharp
5a914cb35b fix: handle exit(2) better 2017-12-29 10:55:12 +00:00
Remy Sharp
1d88943394 fix: pass stdin to child process on -I
Fixes #1036 - the no-stdin wasn't passing the process.stdin to the
child.
2017-12-20 23:21:06 +00:00
Remy Sharp
d15cf686f7 fix: remove scoped dep
Fixes #1180
2017-12-20 14:09:03 +00:00
Remy Sharp
1171fc1a9a fix: nodemon reporting crash
Fixes #1173
2017-12-16 01:17:47 +00:00
Remy Sharp
e9129c03f8 fix: switch to killing using numericals
Fixes #956
Fixes #813
2017-12-15 15:05:20 +00:00
Remy Sharp
bf9b7a6876 fix: if no ps, walk /proc to kill child fully
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.
2017-12-15 14:14:26 +00:00
Remy Sharp
fd961d6053 fix: defensive check on accessing cmd.args 2017-12-13 22:17:13 +00:00
Remy Sharp
d9e93ad367 fix: support node arguments again
If node is being passed any arguments (before the script) then use
spawn instead of fork.

Fixes #1161
2017-12-13 21:08:33 +00:00
Remy Sharp
f52615c0f7 fix: only use fork if node>4 2017-12-13 13:08:05 +00:00
Timothy Huang
cf923a8a77 fix: get tests to pass 2017-12-06 14:45:17 -08:00
Tim
f711fb7889 test: fork child node processes 2017-12-06 14:45:10 -08:00
Remy Sharp
6a4fb22602 fix: pass through execArgs from config (#1142)
* fix: pass through execArgs from config

Also updating some deps and linting tweaks

* chore: add message on postinstall

Lost funds from gratipay and codesponsor 😢
2017-12-05 18:01:55 +00:00
GerA
469fa80aa7 fix: crash when passing argument to node (windows)
Fixes #1095
2017-09-15 07:40:25 +01:00
Brian Dentino
facc8cb2c7 fix: exit with code 1 on crash if --exitcrash (#946)
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.
2017-09-04 20:16:40 +01:00
Attila Hajdrik
481dc8f8ef fix: executable path handling under windows (#962)
- 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.
2017-09-04 19:47:52 +01:00