Skip to content

Commit b6f3688

Browse files
committed
Adding required changes
Except for the handling of the disconnect signal all changes were valid and prove to work on windows.
1 parent 2ca3650 commit b6f3688

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

livereload.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
const { spawn } = require("child_process");
33
const { normalize } = require("path");
44

5-
const termiateSignals = ["close", "exit", ""];
5+
// 'disconnect' is not needed as it will only be raised, when either the child process or this process calss disconnect explicitly.
6+
// We are abel to ensure, that this will never happen, as we do not need communication with the spawned subprocess
7+
const terminationSignal = ["close", "exit"];
68

79
function startSubprocess() {
810
return new Promise((res, rej) => {
9-
const proc = spawn(process.argv.slice(2).map(normalize).join(" "), {
11+
const [command, ...args] = process.argv.slice(2);
12+
const proc = spawn(normalize(command), args, {
1013
stdio: ["pipe", "pipe", "pipe"],
1114
shell:
1215
process.platform === "win32" ||
@@ -15,7 +18,7 @@ function startSubprocess() {
1518
proc.stdout.pipe(process.stdout);
1619
proc.stderr.pipe(process.stderr);
1720
process.stdin.pipe(proc.stdin);
18-
termiateSignals.forEach((e) => proc.on(e, res));
21+
terminationSignal.forEach((event) => proc.on(event, res));
1922
proc.on("error", rej);
2023
});
2124
}

0 commit comments

Comments
 (0)