Skip to content

Commit 958c0b6

Browse files
fix(publish): Change prepare to prepublishOnly
## Summary - Convert `prepare` hook to a (not-equivalent) `prepublishOnly`, reducing the number of times unit tests are run in `prepare`-literate builds by 1. #129 introduced a regression where unit tests stopped being run for Node.js v4 and v6. Prior to that PR, unit tests were run - v4 and v6: once - v8, v9, v10, ... (versions whose npm understands the `prepare` hook): twice After that PR was merged, the number of times unit tests were run in each build went down by 1, _for every build_. That means v4 and v6 stopped running unit tests altogether. 2faa9c4 fixed the regression by unconditionally running unit tests on all matrix-based builds (and explicitly adding a build to run xbrowser tests). With this, Node.js 8+ builds resumed running unit tests twice ([example](https://travis-ci.org/optimizely/javascript-sdk/jobs/399704185)). Regarding the `prepare` hook: npm@4 added the [`prepare`](https://docs.npmjs.com/misc/scripts#prepublish-and-prepare) hook with that fires on prepublish and postinstall. This is strange. Why run tests when someone installs the package? They see the mocha output in their shell, which is likely to surprise. This PR stops the unconventional test runs on postinstall. ## Test plan CI.
1 parent 2faa9c4 commit 958c0b6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/optimizely-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lint": "eslint lib/**",
1111
"cover": "istanbul cover _mocha ./lib/*.tests.js ./lib/**/*.tests.js ./lib/**/**/*tests.js",
1212
"coveralls": "npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls",
13-
"prepare": "npm test"
13+
"prepublishOnly": "npm test && npm run test-xbrowser"
1414
},
1515
"repository": {
1616
"type": "git",

0 commit comments

Comments
 (0)