Skip to content

Commit 720c304

Browse files
brushmateRomanHotsiy
authored andcommitted
fix(cli): return 1 as exit code if an error happens in the cli (#516)
1 parent ac7372b commit 720c304

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

cli/index.ts

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,12 @@ YargsParser.command(
6060
return yargs;
6161
},
6262
async argv => {
63-
try {
64-
await serve(argv.port, argv.spec, {
65-
ssr: argv.ssr,
66-
watch: argv.watch,
67-
templateFileName: argv.template,
68-
redocOptions: argv.options || {},
69-
});
70-
} catch (e) {
71-
console.log(e.stack);
72-
}
63+
await serve(argv.port, argv.spec, {
64+
ssr: argv.ssr,
65+
watch: argv.watch,
66+
templateFileName: argv.template,
67+
redocOptions: argv.options || {},
68+
});
7369
},
7470
)
7571
.command(
@@ -103,18 +99,14 @@ YargsParser.command(
10399
return yargs;
104100
},
105101
async argv => {
106-
try {
107-
await bundle(argv.spec, {
108-
ssr: true,
109-
output: argv.o,
110-
cdn: argv.cdn,
111-
title: argv.title,
112-
templateFileName: argv.template,
113-
redocOptions: argv.options || {},
114-
});
115-
} catch (e) {
116-
console.log(e.message);
117-
}
102+
await bundle(argv.spec, {
103+
ssr: true,
104+
output: argv.o,
105+
cdn: argv.cdn,
106+
title: argv.title,
107+
templateFileName: argv.template,
108+
redocOptions: argv.options || {},
109+
});
118110
},
119111
)
120112
.demandCommand()
@@ -125,6 +117,10 @@ YargsParser.command(
125117
})
126118
.options('options', {
127119
describe: 'ReDoc options, use dot notation, e.g. options.nativeScrollbars',
120+
})
121+
.fail((message, error) => {
122+
console.log(error.stack);
123+
process.exit(1);
128124
}).argv;
129125

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

0 commit comments

Comments
 (0)