Skip to content

Commit

Permalink
Handle exec errors. Record failing command
Browse files Browse the repository at this point in the history
  • Loading branch information
RoboPhred committed Jun 23, 2016
1 parent e255042 commit 5ee688c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions in.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ process.stdin.on("data", stdin => {
// TODO: We can generate an incredible amount of output for large repos.
// Stream this and check each line as it passes.
if (stderr && stderr !== "") {
fail(new Error(stderr));
fail(new Error(stderr), cmdLine);
}

if(err) {
fail(err, cmdLine);
}

const lines = stdout.split('\n');
if (lines.length <= 1) {
fail(new Error("no output from svn checkout"));
fail(new Error("no output from svn checkout"), cmdLine);
}

// "Checked out revision 47830."
Expand All @@ -78,7 +82,7 @@ process.stdin.on("data", stdin => {
const revLine = lines[lines.length - 2];
const header = "Checked out revision ";
if (revLine.substr(0, header.length) !== header) {
fail(new Error('unexpected svn output. expected revision, got "' + lines.slice(lines.length - 5).join("\n") + '"'));
fail(new Error('unexpected svn output. expected revision, got "' + lines.slice(lines.length - 5).join("\n") + '"'), cmdLine);
}

const rev = revLine.substr(header.length, revLine.length - header.length - 2);
Expand Down
5 changes: 4 additions & 1 deletion shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ function prettyJson(obj) {
}
exports.prettyJson = prettyJson;

exports.fail = function fail(err) {
exports.fail = function fail(err, cmd) {
if (cmd) {
console.error('Error while executing command:', filter_hidden(cmd));
}
if (err) {
console.error(filter_hidden(err.stack));
}
Expand Down

0 comments on commit 5ee688c

Please sign in to comment.