Files
bun.sh/test/js/node/process/process-stdin-echo.js
Liz 8f42d8c2dd fix: emit close on stdin stream end (#6720)
* fix: emit close on stdin stream end

We where not emitting the `close` event when done reading stdin data.
It took me way too long to find this but i kept searching in zig/cpp code of the stream implementations...

Fixes: https://github.com/oven-sh/bun/issues/6713

* fix: don't emit close twice
2023-10-26 17:00:37 -07:00

12 lines
369 B
JavaScript

process.stdin.setEncoding("utf8");
process.stdin.on("data", data => {
process.stdout.write(data);
});
process.stdin.once(process.argv[2] == "close-event" ? "close" : "end", () => {
process.stdout.write(process.argv[2] == "close-event" ? "ENDED-CLOSE" : "ENDED");
});
if (process.argv[2] == "resume") {
process.stdout.write("RESUMED");
process.stdin.resume();
}