Tell us about your environment
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
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
commanderand their examples useprocess.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. Theprocess.exitCodeproperty 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.