Skip to content

Commit

Permalink
Merge pull request #303 from DerekTBrown/fix_display_stderr_on_comman…
Browse files Browse the repository at this point in the history
…d_failure

[bugfix] display stderr on command failure
  • Loading branch information
ailisp authored Nov 22, 2022
2 parents 43ca465 + b69c2a2 commit 852bf34
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
24 changes: 15 additions & 9 deletions lib/cli/utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 15 additions & 11 deletions src/cli/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,26 @@ export async function executeCommand(
signale.info(`Running command: ${command}`);
}

try {
const { stdout, stderr } = await exec(command);

let stdout, stderr, code = 0;
try {
({ stdout, stderr } = await exec(command));
} catch (error) {
({ stdout, stderr, code} = error);
}
if(code != 0) {
signale.error(`Command failed: ${command}`);
}
if (stderr && verbose) {
signale.error(stderr);
signale.error(`Command stderr: ${stderr}`);
}

if (verbose) {
signale.info(`Command output: ${stdout}`);
signale.info(`Command stdout: ${stdout}`);
}
if(code != 0){
process.exit(1);
}

return stdout.trim();
} catch (error) {
signale.error(error);
process.exit(1);
}

}

export async function download(url: string, verbose = false) {
Expand Down

0 comments on commit 852bf34

Please sign in to comment.