Skip to content

Commit

Permalink
feat: raw exec output when stdout/stderr are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jun 8, 2022
1 parent a8c890f commit b93e8bc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/execCmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,14 @@ const addJsonOutput = <T extends ExecCmdResult, U>(cmd: string, result: T): T =>
};

const getExitCodeError = (cmd: string, expectedCode: number, output: ShellString) => {
const errorDetails = `\nstdout=${output.stdout}\nstderr=${output.stderr}`;
const errorDetails =
output.stdout || output.stderr
? // return details if they exist
`\nstdout=${output.stdout}\nstderr=${output.stderr}`
: // or the raw string if there are no details
`\n${output}`;
return Error(
`Unexpected exit code for command: ${cmd}. Expected: ${expectedCode} Actual: ${output.code}${errorDetails}`
`Unexpected exit code for command: ${cmd}. Expected: ${expectedCode} Actual: ${output.code} ${errorDetails}`
);
};

Expand Down

0 comments on commit b93e8bc

Please sign in to comment.