Nicer messages in command-line mode on read/write errors

redux
David Majda 14 years ago
parent 957b96c1b5
commit d5caaa7877

@ -103,13 +103,25 @@ switch (args.length) {
var inputStream = process.openStdin();
var outputStream = process.stdout;
break;
case 1:
case 2:
var inputStream = fs.createReadStream(args[0]);
var outputStream = fs.createWriteStream(
args.length == 1 ? args[0].replace(/\.[^.]*$/, ".js") : args[1]
);
var inputFile = args[0];
var inputStream = fs.createReadStream(inputFile);
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;
default:
abort("Too many arguments.");
}

Loading…
Cancel
Save