Skip to content

Commit bb24acd

Browse files
edvaldeysi09
authored andcommitted
fix(cli): set error code when calling CLI with bad command
1 parent d8fd6de commit bb24acd

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/cli/cli.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,13 @@ export class GardenCli {
264264
if (cliOutput && errors.length < 1) {
265265
logger.stop()
266266
console.log(cliOutput)
267-
process.exit(parseResult.code)
267+
268+
// fix issue where sywac returns exit code 0 even when a command doesn't exist
269+
if (!argv.h && !argv.help) {
270+
code = 1
271+
}
272+
273+
process.exit(code)
268274
}
269275

270276
const gardenErrors: GardenError[] = errors

test/integ/run

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ cd ${garden_root}/examples/hello-world
88

99
export GARDEN_LOGGER_TYPE=basic
1010

11+
# make sure CLI returns with error when it should
12+
set +e
13+
14+
${garden_bin} bla
15+
if [[ $? -eq 0 ]]; then
16+
echo "Expected error when calling with bad command"
17+
exit 1
18+
fi
19+
20+
set -e
21+
1122
${garden_bin} scan
1223
${garden_bin} build
1324
${garden_bin} deploy

0 commit comments

Comments
 (0)