Original Discussion: https://www.pika.dev/npm/snowpack/discuss/244
/cc @quasor, @acoyfellow, @FredKSchott
It should only require one.
So, I don't know if this is a Windows specific issue (I'm using Powershell on Windows 10), but I did find a sort of workaround here:
https://stackoverflow.com/questions/10021373/what-is-the-windows-equivalent-of-process-onsigint-in-node-js
Effectively creating a custom handler for the user input for Ctrl+C on Windows and then having that method process the "SIGINT" event so it gets picked up properly by the handler.
// Inside \\node_modules\snowpack\dist-src\commands\dev.js
// but edited directly in \\node_modules\snowpack\dist-node\index.js
if (process.platform === "win32") {
var rl = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
rl.on("SIGINT", function() {
process.emit("SIGINT");
});
}
process.on("SIGINT", function() {
hmrEngine.disconnectAllClients();
process.exit(0);
});
It works, but causes no confirmation message to appear - need to look into that.
Interestingly though, CTRL+Break works fine on Windows without the above "fix".
FWIW I鈥檓 on latest MacOS when reporting.
FWIW I鈥檓 on latest MacOS when reporting.
I suppose it's possible to remove the windows check and manually handle the user input regardless of OS... I haven't tried on my Mac yet though.
I noticed this on my windows machine as well using Git Bash
FWIW I鈥檓 on latest MacOS when reporting.
Confirms... the "fix" also works for Mac by removing the if statement:
// Inside \\node_modules\snowpack\dist-src\commands\dev.js
// but edited directly in \\node_modules\snowpack\dist-node\index.js
var rl = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
rl.on("SIGINT", function() {
process.emit("SIGINT");
});
process.on("SIGINT", function() {
hmrEngine.disconnectAllClients();
process.exit(0);
});
I read somewhere that it's possible one of the other watchers is swallowing the initial ctrl+c command from the user, but I've not looked into that yet.
I noticed this on my windows machine as well using Git Bash
I noticed the same thing as well. Implementing the above does work on Git Bash as well.
Sounds like that's the fix then for all environments. Would love a PR if you can add one, @mojiwa!
Sounds like that's the fix then for all environments. Would love a PR if you can add one, @mojiwa!
Absolutely. I'll raise one this evening.
Resolved via #380