blob: a3683fe9eeb389eddb5bbfd2d84d980111d9fa6f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import child_process from "node:child_process";
import { Buffer } from "node:buffer";
import console from "node:console";
const child = child_process.spawn("./test-pipe/target/debug/test-pipe", [], {
stdio: ["inherit", "inherit", "inherit", "ignore", "pipe"],
});
const extra = child.stdio[4];
const p = Promise.withResolvers();
child.on("close", () => {
console.log("child closed");
p.resolve();
});
extra.on("data", (d) => {
console.log("data:", d.toString().trim());
});
extra.on("close", () => {
console.log("pipe closed");
});
await p.promise;
|