Skip to content

Commit

Permalink
feat(cli): hide stack trace on subprocess errors
Browse files Browse the repository at this point in the history
  • Loading branch information
motiz88 committed May 20, 2018
1 parent 1647197 commit 5d5bf53
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ async function main(argv = []) {
);
}
const fullyStaged = await getFullyStaged(files);
await spawn(command, commandArgs.concat(files), { stdio: "inherit" });
try {
await spawn(command, commandArgs.concat(files), { stdio: "inherit" });
} catch (e) {
e.__isExpectedError = true;
e.message = "Error running command: " + e.message;
throw e;
}
if (fullyStaged.length) {
await stageFiles(fullyStaged);
}
Expand All @@ -42,7 +48,7 @@ export default main;
if (require.main === module) {
require("./polyfills");
main(process.argv.slice(2)).catch(e => {
if (e instanceof CliError) {
if (e instanceof CliError || e.__isExpectedError) {
process.stderr.write(e.message + "\n");
} else {
process.stderr.write(e.stack || e);
Expand Down

0 comments on commit 5d5bf53

Please sign in to comment.