Nicer messages in command-line mode on read/write errors
This commit is contained in:
parent
957b96c1b5
commit
d5caaa7877
20
bin/pegjs
20
bin/pegjs
|
@ -103,13 +103,25 @@ switch (args.length) {
|
||||||
var inputStream = process.openStdin();
|
var inputStream = process.openStdin();
|
||||||
var outputStream = process.stdout;
|
var outputStream = process.stdout;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
var inputStream = fs.createReadStream(args[0]);
|
var inputFile = args[0];
|
||||||
var outputStream = fs.createWriteStream(
|
var inputStream = fs.createReadStream(inputFile);
|
||||||
args.length == 1 ? args[0].replace(/\.[^.]*$/, ".js") : args[1]
|
inputStream.on("error", function() {
|
||||||
);
|
abort("Can't read from file \"" + inputFile + "\".");
|
||||||
|
});
|
||||||
|
|
||||||
|
var outputFile = args.length == 1
|
||||||
|
? args[0].replace(/\.[^.]*$/, ".js")
|
||||||
|
: args[1];
|
||||||
|
var outputStream = fs.createWriteStream(outputFile);
|
||||||
|
outputStream.on("error", function() {
|
||||||
|
abort("Can't write to file \"" + outputFile + "\".");
|
||||||
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
abort("Too many arguments.");
|
abort("Too many arguments.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue