Skip to content

Commit

Permalink
fix: add both stdout and stderr to getExitCodeError
Browse files Browse the repository at this point in the history
  • Loading branch information
shetzel committed Feb 10, 2022
1 parent 615d3b5 commit 49cccd7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/execCmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ const addJsonOutput = <T extends ExecCmdResult, U>(cmd: string, result: T): T =>
};

const getExitCodeError = (cmd: string, expectedCode: number, output: ShellString) => {
const io = cmd.includes('--json') ? output.stdout : output.stderr;
return Error(`Unexpected exit code for command: ${cmd}. Expected: ${expectedCode} Actual: ${output.code}\n${io}`);
const errorDetails = `\nstdout=${output.stdout}\nstderr=${output.stderr}`;
return Error(
`Unexpected exit code for command: ${cmd}. Expected: ${expectedCode} Actual: ${output.code}${errorDetails}`
);
};

/**
Expand Down

0 comments on commit 49cccd7

Please sign in to comment.