Skip to content

Commit 0526624

Browse files
build(npm): short-circuit npm install if node_modules are healthy
Closes angular#8627
1 parent 4ddf553 commit 0526624

File tree

4 files changed

+3
-18
lines changed

4 files changed

+3
-18
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"url": "https://github.com/angular/angular.git"
1616
},
1717
"scripts": {
18-
"preinstall": "node tools/npm/check-node-modules",
1918
"postinstall": "node tools/npm/copy-npm-shrinkwrap"
2019
},
2120
"dependencies": {

scripts/ci-lite/install.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,8 @@ echo 'travis_fold:end:install-npm'
2727

2828

2929
# Install all npm dependencies according to shrinkwrap.json
30-
# note: package.json contain preinstall and postintall hooks that can short-circuit
31-
# the installation if node_modules is up to date
3230
echo 'travis_fold:start:install.node_modules'
33-
if [[ ${TRAVIS} ]]; then
34-
node tools/npm/check-node-modules --purge
35-
fi
36-
npm install
31+
node tools/npm/check-node-modules --purge || npm install
3732
echo 'travis_fold:end:install.node_modules'
3833

3934

tools/npm/check-node-modules

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@ var checkNpm = require('./check-node-modules.js');
44

55
var purgeIfStale = (process.argv.indexOf('--purge') !== -1);
66

7-
if (process.env.TRAVIS && !purgeIfStale) {
8-
process.exit(0);
9-
}
10-
117
// check-node-modules will exit(1) if we don't need to install to short-circuit `npm install`
128
// see .travis.yml's `install` block to see the reason for this
139
var nodeModulesOK = checkNpm(true, purgeIfStale);
1410

15-
process.exit( nodeModulesOK || purgeIfStale ? 0 : 1);
11+
process.exit( nodeModulesOK ? 0 : 1);
1612

tools/npm/check-node-modules.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@ function checkNodeModules(logOutput, purgeIfStale) {
1818
if (logOutput) console.error(':-( npm dependencies are stale or in an in unknown state!');
1919
if (purgeIfStale) {
2020
if (logOutput) console.log(' purging...');
21-
22-
var nodeModulesPath = path.join(PROJECT_ROOT, 'node_modules');
23-
24-
if (fs.existsSync(nodeModulesPath)) {
25-
_deleteDir(nodeModulesPath);
26-
}
21+
_deleteDir(path.join(PROJECT_ROOT, 'node_modules'));
2722
}
2823
}
2924

0 commit comments

Comments
 (0)