-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: Add tests and handle piping. (#343)
- Loading branch information
Showing
18 changed files
with
324 additions
and
44 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,3 +74,4 @@ winreg = "0.52.0" | |
|
||
[dev-dependencies] | ||
starbase_sandbox = { workspace = true } | ||
signal-child = "1.0.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this data comes from a file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
process.exitCode = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
process.exit(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
console.log("start"); | ||
|
||
async function getStdinBuffer() { | ||
if (process.stdin.isTTY) { | ||
return Buffer.alloc(0); | ||
} | ||
|
||
const result = []; | ||
let length = 0; | ||
|
||
for await (const chunk of process.stdin) { | ||
result.push(chunk); | ||
length += chunk.length; | ||
} | ||
|
||
return Buffer.concat(result, length); | ||
} | ||
|
||
getStdinBuffer().then((buffer) => { | ||
let data = buffer.toString("utf8"); | ||
|
||
if (data) { | ||
console.log("piped data =", data.trim()); | ||
} | ||
}); | ||
|
||
setTimeout(() => { | ||
console.log("stop"); | ||
}, 2500); | ||
|
||
console.log("running"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
console.log("start"); | ||
|
||
process.on("SIGINT", () => { | ||
console.log("killed"); | ||
process.exit(1); | ||
}); | ||
|
||
setTimeout(() => { | ||
console.log("stop"); | ||
}, 5000); | ||
|
||
console.log("running"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
console.log("stdout"); | ||
console.error("stderr"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
console.log("start"); | ||
|
||
setTimeout(() => { | ||
console.log("stop"); | ||
}, 2500); | ||
|
||
console.log("running"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
console.log("start"); | ||
|
||
await new Promise((resolve) => { | ||
setTimeout(() => { | ||
console.log("running"); | ||
resolve(); | ||
}, 2500); | ||
}); | ||
|
||
console.log("stop"); |
Oops, something went wrong.