From 720c3044841406f6e58d23e658c20459b5b844d7 Mon Sep 17 00:00:00 2001 From: brushmate Date: Tue, 29 May 2018 16:51:15 +0200 Subject: [PATCH] fix(cli): return 1 as exit code if an error happens in the cli (#516) --- cli/index.ts | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/cli/index.ts b/cli/index.ts index 147aee64..6281e5ca 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -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( @@ -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() @@ -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 = {}) {