From a773f89bc96a1aae1f0fecaa4e66476c8f982f20 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sat, 21 Feb 2015 12:08:45 -0800 Subject: [PATCH] chore(grunt): blow away cached node_modules when npm-shrinkwrap.json changes this replicates the travis setup in grunt from the previous commit the reason why we duplicate this rather than having just a single place for this code is so that we can individually time the actions on travis --- .travis.yml | 1 + lib/grunt/utils.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 5ab8a2a10a80..5d740ceaa6b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,6 +46,7 @@ install: # Log HTTP requests - npm config set loglevel http - npm install -g npm@2.5 + # Instal npm dependcies and ensure that npm cache is not stale (these steps are replicated in lib/grunt/utils.js) - diff -q npm-shrinkwrap.json node_modules/npm-shrinkwrap.cached.json; if [[ $? -ne 0 ]]; then echo 'Shrinkwrap changed! Blowing away node_modules.'; rm -rf node_modules; fi - time npm install - cp npm-shrinkwrap.json node_modules/npm-shrinkwrap.cached.json diff --git a/lib/grunt/utils.js b/lib/grunt/utils.js index 4ef97500f1b1..49f53fd1cc4d 100644 --- a/lib/grunt/utils.js +++ b/lib/grunt/utils.js @@ -16,7 +16,10 @@ module.exports = { init: function() { if (!process.env.TRAVIS) { + // replicated from .travis.yaml + shell.exec("diff -q npm-shrinkwrap.json node_modules/npm-shrinkwrap.cached.json; if [[ $? -ne 0 ]]; then echo 'Shrinkwrap changed! Blowing away node_modules.'; rm -rf node_modules; fi"); shell.exec('npm install'); + shell.exec('cp npm-shrinkwrap.json node_modules/npm-shrinkwrap.cached.json'); } },