blob: 1617a8588420dcd735e44a3b6346da7d266ae199 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
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);
});
|