mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
22 lines
446 B
JavaScript
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);
|
|
});
|