Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(build): short-circuit npm install if node_modules are healthy #8627

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -15,7 +15,6 @@
"url": "https://github.com/angular/angular.git"
},
"scripts": {
"preinstall": "node tools/npm/check-node-modules",
"postinstall": "node tools/npm/copy-npm-shrinkwrap"
},
"dependencies": {
Expand Down
7 changes: 1 addition & 6 deletions scripts/ci-lite/install.sh
Expand Up @@ -27,13 +27,8 @@ echo 'travis_fold:end:install-npm'


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


Expand Down
6 changes: 1 addition & 5 deletions tools/npm/check-node-modules
Expand Up @@ -4,13 +4,9 @@ var checkNpm = require('./check-node-modules.js');

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

if (process.env.TRAVIS && !purgeIfStale) {
process.exit(0);
}

// check-node-modules will exit(1) if we don't need to install to short-circuit `npm install`
// see .travis.yml's `install` block to see the reason for this
var nodeModulesOK = checkNpm(true, purgeIfStale);

process.exit( nodeModulesOK || purgeIfStale ? 0 : 1);
process.exit( nodeModulesOK ? 0 : 1);

7 changes: 1 addition & 6 deletions tools/npm/check-node-modules.js
Expand Up @@ -18,12 +18,7 @@ function checkNodeModules(logOutput, purgeIfStale) {
if (logOutput) console.error(':-( npm dependencies are stale or in an in unknown state!');
if (purgeIfStale) {
if (logOutput) console.log(' purging...');

var nodeModulesPath = path.join(PROJECT_ROOT, 'node_modules');

if (fs.existsSync(nodeModulesPath)) {
_deleteDir(nodeModulesPath);
}
_deleteDir(path.join(PROJECT_ROOT, 'node_modules'));
}
}

Expand Down