fix: make @babel/node spawned process bubble msg (#13037)
* Add ipc test Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This commit is contained in:
parent
afef4f85ff
commit
b360d8d614
@ -96,6 +96,7 @@ getV8Flags(async function (err, v8Flags) {
|
||||
}
|
||||
});
|
||||
});
|
||||
proc.on("message", message => process.send && process.send(message));
|
||||
process.on("SIGINT", () => proc.kill("SIGINT"));
|
||||
}
|
||||
});
|
||||
|
||||
1
packages/babel-node/test/fixtures/misc/child.js
vendored
Normal file
1
packages/babel-node/test/fixtures/misc/child.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
process.send("hello");
|
||||
27
packages/babel-node/test/index.js
Normal file
27
packages/babel-node/test/index.js
Normal file
@ -0,0 +1,27 @@
|
||||
import { spawn } from "child_process";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const binLoc = path.join(dirname, "../bin/babel-node.js");
|
||||
const childLoc = path.join(dirname, "fixtures/misc/child.js");
|
||||
|
||||
describe("babel-node", () => {
|
||||
it("ipc works with spawned babel-node process", done => {
|
||||
expect.assertions(1);
|
||||
|
||||
const child = spawn(process.execPath, [binLoc, childLoc], {
|
||||
stdio: ["inherit", "inherit", "inherit", "ipc"],
|
||||
});
|
||||
|
||||
child.on("message", msg => {
|
||||
expect(msg).toBe("hello");
|
||||
done();
|
||||
});
|
||||
child.on("error", error => {
|
||||
console.error(error);
|
||||
done();
|
||||
});
|
||||
child.on("exit", () => done());
|
||||
}, /* timeout */ 20_000);
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user