Files
bun.sh/test/bun.js/bun-spawn-test.js
Derrick Farris 9ccc455f8d Fix child_process tests (#1471)
* test(child_process): fix broken tests, add our-assert pkg for testing

* test(child_process): replace console.log with debug()

* test(child_process): rename our-assert -> node-test-helpers, use Bun.peek for subproc.exited
2022-11-08 15:33:47 -08:00

22 lines
446 B
JavaScript

const EventEmitter = import.meta.require("events");
class TestClass extends EventEmitter {
#handle = null;
spawn() {
this.#handle = Bun.spawn(["pwd"], {
cwd: "/tmp",
onExit: this.#handleOnExit.bind(this),
});
}
#handleOnExit(code) {
console.log(code);
this.emit("exit");
}
}
const testClass = new TestClass();
testClass.spawn();
testClass.on("exit", () => {
console.log("exiting");
process.exit(0);
});