Skip to content

Commit

Permalink
fix: wrap installs in try/catch blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasnorrby committed Dec 19, 2019
1 parent 8d18110 commit ab67afd
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,25 @@ const spinner = ora({
color: "blue",
});

const runCommand = async cmd => {
try {
spinner.start();
await execa.command(cmd);
spinner.stop();
} catch (error) {
spinner.stop();
log.fail(error);
process.exit(1);
}
};

(async () => {
log.info("Installing peer dependencies (semantic-release)");
spinner.start();
await execa.command(`${pkgInstallDev} semantic-release`);
spinner.stop();
await runCommand(`${pkgInstallDev} semantic-release`);

if (argv.install) {
log.info(`Installing self (${packageName})`);
spinner.start();
await execa.command(`${pkgInstallDev} ${packageName}`);
spinner.stop();
await runCommand(`${pkgInstallDev} ${packageName}`);
} else {
log.skip("Skipping install of self");
}
Expand Down

0 comments on commit ab67afd

Please sign in to comment.