What I Wanted to Do
I run tests in my preversion
script. When I run npm version ...
I expect that if preversion
fails because of a failed test, then the preversion
should quit and the version
process should not continue.
What Happened Instead
If I run npm run preversion
and it fails then echo $?
shows a non-zero exit code as expected.
However, when I run npm version patch -m 'v%s'
or similar, and the preversion
part fails, the version process continues and eventually tries to publish the erroneous package to NPM.
Reproduction Steps
I have a branch here: https://github.com/trusktr/infamous/tree/npm.community/t/3913
To reproduce, try the following after cloning and checking out that branch:
npm install
npm run test # note that it fails with exit code 255
npm run preversion # note that it fails with exit code 1
npm version patch -f -m "v%s" # it will not fail, it continues past preversion failure
Platform Info
$ npm --versions
{ infamous: '21.0.5',
npm: '6.4.1',
ares: '1.14.0',
cldr: '33.1',
http_parser: '2.8.0',
icu: '62.1',
modules: '64',
napi: '3',
nghttp2: '1.32.0',
node: '10.9.0',
openssl: '1.1.0i',
tz: '2018e',
unicode: '11.0',
uv: '1.22.0',
v8: '6.8.275.24-node.14',
zlib: '1.2.11' }
$ node -p process.platform
darwin