Skip to content

Commit

Permalink
fix(cli): return 1 as exit code if an error happens in the cli (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
brushmate authored and RomanHotsiy committed May 29, 2018
1 parent ac7372b commit 720c304
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,12 @@ YargsParser.command(
return yargs;
},
async argv => {
try {
await serve(argv.port, argv.spec, {
ssr: argv.ssr,
watch: argv.watch,
templateFileName: argv.template,
redocOptions: argv.options || {},
});
} catch (e) {
console.log(e.stack);
}
await serve(argv.port, argv.spec, {
ssr: argv.ssr,
watch: argv.watch,
templateFileName: argv.template,
redocOptions: argv.options || {},
});
},
)
.command(
Expand Down Expand Up @@ -103,18 +99,14 @@ YargsParser.command(
return yargs;
},
async argv => {
try {
await bundle(argv.spec, {
ssr: true,
output: argv.o,
cdn: argv.cdn,
title: argv.title,
templateFileName: argv.template,
redocOptions: argv.options || {},
});
} catch (e) {
console.log(e.message);
}
await bundle(argv.spec, {
ssr: true,
output: argv.o,
cdn: argv.cdn,
title: argv.title,
templateFileName: argv.template,
redocOptions: argv.options || {},
});
},
)
.demandCommand()
Expand All @@ -125,6 +117,10 @@ YargsParser.command(
})
.options('options', {
describe: 'ReDoc options, use dot notation, e.g. options.nativeScrollbars',
})
.fail((message, error) => {
console.log(error.stack);
process.exit(1);
}).argv;

async function serve(port: number, pathToSpec: string, options: Options = {}) {
Expand Down

0 comments on commit 720c304

Please sign in to comment.