diff options
Diffstat (limited to 'test/bun.js/spawned-child.js')
-rw-r--r-- | test/bun.js/spawned-child.js | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/test/bun.js/spawned-child.js b/test/bun.js/spawned-child.js index a90dfade2..d39131933 100644 --- a/test/bun.js/spawned-child.js +++ b/test/bun.js/spawned-child.js @@ -1,33 +1,27 @@ const TARGET = process.argv[2]; const MODE = process.argv[3]; -async function main() { - if (TARGET === "STDIN") { - let data = ""; - process.stdin.setEncoding("utf8"); - if (MODE === "READABLE") { - process.stdin.on("readable", () => { - let chunk; - while ((chunk = process.stdin.read()) !== null) { - data += chunk; - } - }); - } else { - process.stdin.on("data", (chunk) => { +if (TARGET === "STDIN") { + let data = ""; + process.stdin.setEncoding("utf8"); + if (MODE === "READABLE") { + process.stdin.on("readable", () => { + let chunk; + while ((chunk = process.stdin.read()) !== null) { data += chunk; - }); - } - process.stdin.on("end", () => { - console.log("data:", data); - process.exit(0); + } }); - } else if (TARGET === "STDOUT") { - process.stdout.write("stdout_test"); - } else if (TARGET === "TIMER") { - setTimeout(() => console.log("hello"), 150); } else { - console.log("unknown target! you messed up..."); + process.stdin.on("data", (chunk) => { + data += chunk; + }); } + process.stdin.on("end", () => { + process.stdout.write("data: "); + process.stdout.write(data); + }); +} else if (TARGET === "STDOUT") { + process.stdout.write("stdout_test"); +} else { + console.log("unknown target! you messed up..."); } - -main(); |