Fix: Only create @babel/node IPC channel when needed (#13295)

Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
This commit is contained in:
Clark Jacobsohn
2021-05-11 17:59:07 -04:00
committed by GitHub
parent 875fc8e693
commit cca97d1e78
8 changed files with 38 additions and 35 deletions

View File

@@ -84,8 +84,12 @@ getV8Flags(async function (err, v8Flags) {
throw err;
}
// passthrough IPC only if babel-node itself has an IPC channel
const shouldPassthroughIPC = process.send !== undefined;
const proc = child_process.spawn(process.argv[0], args, {
stdio: ["inherit", "inherit", "inherit", "ipc"],
stdio: shouldPassthroughIPC
? ["inherit", "inherit", "inherit", "ipc"]
: "inherit",
});
proc.on("exit", function (code, signal) {
process.on("exit", function () {
@@ -96,7 +100,9 @@ getV8Flags(async function (err, v8Flags) {
}
});
});
proc.on("message", message => process.send && process.send(message));
if (shouldPassthroughIPC) {
proc.on("message", message => process.send(message));
}
process.on("SIGINT", () => proc.kill("SIGINT"));
}
});