- Nov
- 4
- 0
Using TCC/LE 14.00.6 x64, commands chained with && in npm scripts do not short circuit, e.g. a nonzero exit code does not stop the next command from running.
For example in a package.json:
{
scripts: {
pretest: "eslint ./src && npm run build",
test: "mocha ./test"
}
}
Running "npm test" from a normal DOS shell, if "eslint ./src" fails, then the next command will not run. Under TCC, however, the exit codes seem to be ignored, and every step runs to completion regardless of outcome.
I tried to reproduce this without using npm scripts - e.g. if I just create a simple node.js app that exists with code zero, and do:
> node app1 && node app2
then it works as expected. So it has something to do with the way npm runs scripts -- in that I believe it launches a new shell instance for the script, and maybe this causes the exit code to get lost? But I can't blame npm since this works fine with a regular cmd shell.
For example in a package.json:
{
scripts: {
pretest: "eslint ./src && npm run build",
test: "mocha ./test"
}
}
Running "npm test" from a normal DOS shell, if "eslint ./src" fails, then the next command will not run. Under TCC, however, the exit codes seem to be ignored, and every step runs to completion regardless of outcome.
I tried to reproduce this without using npm scripts - e.g. if I just create a simple node.js app that exists with code zero, and do:
> node app1 && node app2
then it works as expected. So it has something to do with the way npm runs scripts -- in that I believe it launches a new shell instance for the script, and maybe this causes the exit code to get lost? But I can't blame npm since this works fine with a regular cmd shell.