fix: add support for SIGINT on Windows (fixes issue #1720) #1853
This commit adds an install script that runs on 'npm install'. Its purpose is to download, extract and verify a specific version of the windows-kill.exe binary. I decided not add the - windows only - executable directly to this project to keep the dependencies clear. Furthermore I did not use the node-window-kill package, because it comes with node-gyp which requires python and vs2017 build tools on the target machine.
This commit replaces the taskkill invocation with windows-kill.exe. We are now sending a SIGINT POSIX signal to the node process in a Windows context. Known issues: The windows-kill.exe has to be triggered in a detached process context, which currently flashes a terminal window on each reload. Furthermore the 'restart' event is triggered twice on the bus.
This commit silences all errors from the wmic.exe process. Which is save, because the error case is handled by falling back to the child.pid. It also optimizes the windows-kill invocation by minimizing (hiding) the terminal window and keeping it open until the process has finished.
…1720) This commit replaces the provisioning script, which downloaded a specific windows-kill.exe binary, with the binary itself. We are using the x64 version of the windows-kill.exe from: https://github.com/ElyDotDev/windows-kill/releases/tag/1.1.4 We are now embedding the binary with the project directly to decrease the complexity and avoid breaking the build by external changes. Actually the maintainer of windows-kill changed his GitHub username recently from "alirdn" to "ElyDotDev" which broke the provisioning script!
This commit adds back the hard shutdown behaviour under Windows as an opt-in: If the --signal option is "SIGKILL" nodemon will terminate the process group by force without waiting for the process to clean-up. This matches a SIGKILL on a UNIX system.
I get this with the latest version.
The system cannot find the file C:\Projects\node.js\complete-node-bootcamp\4-natours\starter\node_modules\nodemon\bin\windows-kill.exe.
I've initially installed nodemon globally, without adding it to the project dependencies. I've fixed this by doing a npm i nodemon --save-dev too.
Shouldn't it work by installing it globally only? It did before.