Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 61734ca

Browse files
committed
fix: Terminate node if no input from stdin
1 parent 3a4d2ad commit 61734ca

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: index.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,14 @@ const options = minimist(process.argv.slice(2), {
215215
});
216216

217217
const stdinCode: string[] = [];
218-
process.stdin.resume();
219-
process.stdin.on('data', (data: Buffer) => {
220-
stdinCode.push(data.toString());
218+
process.stdin.on('readable', () => {
219+
const chunk = process.stdin.read();
220+
if (chunk !== null) {
221+
stdinCode.push(chunk.toString());
222+
} else {
223+
// No stdin -> let node terminate
224+
process.stdin.pause();
225+
}
221226
});
222227
process.stdin.on('end', () => {
223228
if (!options.name) {

0 commit comments

Comments
 (0)