Navigation Menu

Skip to content

Commit

Permalink
Detect npm >=3.9.2 and adjust the install command accordingly
Browse files Browse the repository at this point in the history
npm v3.9.1 included a fix for the bug which makes the `rm -rf
node_modules` necessary ( npm/npm#12372 ), but
also exposed a different bug which was fixed in npm v3.9.2
( npm/npm#12724 )
  • Loading branch information
misterbyrne committed Jul 6, 2016
1 parent 6a3d4d1 commit 157b327
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/reporter.js
@@ -1,16 +1,32 @@
'use strict';
var versionChecker = require('./version-checker');

function installCommand(type) {
switch (type) {
case 'npm':
return 'npm install';
case 'npm-shrinkwrap':
// npm v3.9.1 included a fix for the bug which makes the rm -rf node_modules
// necessary ( https://github.com/npm/npm/issues/12372 ), but also exposed
// a different bug which was fixed in npm v3.9.2
// ( https://github.com/npm/npm/pull/12724 )
if (versionChecker.satisfies('>=3.9.2', getNpmVersion())) {
return 'npm install';
}
return 'rm -rf node_modules/ && npm install';
case 'bower':
return 'bower install';
}
}

function getNpmVersion() {
try {
return require('child_process').execSync('npm -v').toString();
} catch (e) {
}
return undefined;
}

var Reporter = function() {
this.messages = [];
};
Expand Down

0 comments on commit 157b327

Please sign in to comment.