Skip to content

Commit 683d374

Browse files
apaleslimghostMatt Brennan
authored and
Matt Brennan
committed
check if npm properly supports long cache-min and enable if so
1 parent ec60307 commit 683d374

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

global-cli/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,26 @@ function createApp(name, verbose, version) {
101101
run(root, appName, version, verbose, originalDirectory);
102102
}
103103

104+
function getNpmVersion() {
105+
return spawn.sync(
106+
'npm',
107+
['--version'],
108+
{encoding: 'utf8'}
109+
).stdout;
110+
}
111+
112+
function npmSupportsOffline() {
113+
var version = getNpmVersion();
114+
return semver.gt(version, '3.9.0');
115+
}
116+
104117
function run(root, appName, version, verbose, originalDirectory) {
105118
var args = [
106119
'install',
107120
verbose && '--verbose',
108121
'--save-dev',
109122
'--save-exact',
123+
npmSupportsOffline() && '--cache-min=Infinity',
110124
getInstallPackage(version),
111125
].filter(function(e) { return e; });
112126
var proc = spawn('npm', args, {stdio: 'inherit'});

0 commit comments

Comments
 (0)