Skip to content

Commit

Permalink
fix(cli): set error code when calling CLI with bad command
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald authored and eysi09 committed Jun 25, 2018
1 parent d8fd6de commit bb24acd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,13 @@ export class GardenCli {
if (cliOutput && errors.length < 1) {
logger.stop()
console.log(cliOutput)
process.exit(parseResult.code)

// fix issue where sywac returns exit code 0 even when a command doesn't exist
if (!argv.h && !argv.help) {
code = 1
}

process.exit(code)
}

const gardenErrors: GardenError[] = errors
Expand Down
11 changes: 11 additions & 0 deletions test/integ/run
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ cd ${garden_root}/examples/hello-world

export GARDEN_LOGGER_TYPE=basic

# make sure CLI returns with error when it should
set +e

${garden_bin} bla
if [[ $? -eq 0 ]]; then
echo "Expected error when calling with bad command"
exit 1
fi

set -e

${garden_bin} scan
${garden_bin} build
${garden_bin} deploy
Expand Down

0 comments on commit bb24acd

Please sign in to comment.