Markbind: Failed MarkBind commands should exit with nonzero return code

Created on 31 Jan 2019  路  3Comments  路  Source: MarkBind/markbind

Tell us about your environment

  • MarkBind Version: 1.17.1

What did you do? Please include the actual source code causing the issue.
I ran a MarkBind command that failed (exited due to unrecoverable errors). For example, markbind build on a directory that does not have a config file.

What did you expect to happen?
MarkBind should exit with a nonzero return code (eg. 1) to indicate an error condition. This is especially important for running MarkBind in an automated context where other programs or scripts are relying on the exit code of MarkBind to detect errors (eg. as part of a custom build script, or Travis CI automation).

What actually happened? Please include the actual, raw output.
MarkBind exits with a zero return code, incorrectly indicating that MarkBind ran successfully.

On PowerShell:

PS C:\Users\pzy5a> markbind build
error: No config file found in parent directories of C:\Users\pzy5a
PS C:\Users\pzy5a> $LASTEXITCODE
0

On Bash:

pzy5a@Xenon-XPS MINGW64 ~ 
$ markbind build
error: No config file found in parent directories of C:\Users\pzy5a

pzy5a@Xenon-XPS MINGW64 ~
$ echo $?
0

Related: #601

a-CLI c.Bug 馃悰 p.Medium

All 3 comments

In #649, I manually set process.exitCode = 1 on failure of deploy --travis. We could manually do something similar for each command, but I was wondering if there was a more systematic alternative for this?

We're using commander and their examples use process.exit(1);

We're using commander and their examples use process.exit(1);

Using process.exit() is explicitly discouraged by the Node.js documentation though:

In most situations, it is not actually necessary to call process.exit() explicitly. The Node.js process will exit on its own if there is no additional work pending in the event loop. The process.exitCode property can be set to tell the process which exit code to use when the process exits gracefully.

My thought is to have all .catch() in index.js call a common error handler that sets process.exitCode = 1.

Was this page helpful?
0 / 5 - 0 ratings