Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] display stderr on command failure #303

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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