improve CLI usability (#4670)

closes #3308
This commit is contained in:
Alex Lam S.L
2021-02-22 07:27:03 +00:00
committed by GitHub
parent 55b59407e4
commit 960668ccdb
2 changed files with 11 additions and 7 deletions

View File

@@ -260,9 +260,14 @@ if (paths.length) {
});
run();
} else {
var timerId = process.stdin.isTTY && process.argv.length < 3 && setTimeout(function() {
print_error("Waiting for input... (use `--help` to print usage information)");
}, 1500);
var chunks = [];
process.stdin.setEncoding("utf8");
process.stdin.on("data", function(chunk) {
process.stdin.once("data", function() {
clearTimeout(timerId);
}).on("data", function(chunk) {
chunks.push(chunk);
}).on("end", function() {
files = { STDIN: chunks.join("") };