Skip to content

Commit

Permalink
npm cache by default (#940)
Browse files Browse the repository at this point in the history
* fix: test on win32

* feat: adding cache-min Infinity as a default

* fix: use os.EOL as per @SBoudrias suggestion

* feat(npm): use a cache-min of a day and update tests
  • Loading branch information
mklabs authored and SBoudrias committed Oct 23, 2016
1 parent 61d5df1 commit 2c34bde
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions lib/actions/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ install.runInstall = function (installer, paths, options, cb) {

var args = ['install'].concat(paths).concat(dargs(options));

// only for npm, use a minimum cache of one day
if (installer === 'npm') {
args = args.concat(['--cache-min', 24 * 60 * 60]);
}

// Return early if we're skipping installation.
if (this.options.skipInstall) {
cb();
Expand Down
4 changes: 3 additions & 1 deletion test/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ var Promise = require('pinkie-promise');
var yeoman = require('yeoman-environment');
var userHome = require('user-home');

var LF = require('os').EOL;

mockery.enable({
warnOnReplace: false,
warnOnUnregistered: false
Expand Down Expand Up @@ -499,7 +501,7 @@ describe('generators.Base', function () {
});

testGen.run(function () {
assert.equal(fs.readFileSync(filepath, 'utf8'), 'var a = 1;\n');
assert.equal(fs.readFileSync(filepath, 'utf8'), 'var a = 1;' + LF);
done();
});
});
Expand Down
6 changes: 3 additions & 3 deletions test/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('generators.Base (actions/install mixin)', function () {
}
};

//args: installer, paths, options, cb
// args: installer, paths, options, cb
this.dummy.runInstall('nestedScript', ['path1', 'path2'], spawnEnv, callbackSpy);
this.dummy.run(function () {
sinon.assert.calledWithExactly(
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('generators.Base (actions/install mixin)', function () {
this.dummy.npmInstall();
this.dummy.run(function () {
sinon.assert.calledOnce(this.spawnCommandStub);
sinon.assert.calledWithExactly(this.spawnCommandStub, 'npm', ['install'], {});
sinon.assert.calledWithExactly(this.spawnCommandStub, 'npm', ['install', '--cache-min', 86400], {});
done();
}.bind(this));
});
Expand All @@ -141,7 +141,7 @@ describe('generators.Base (actions/install mixin)', function () {
this.dummy.installDependencies(function () {
sinon.assert.calledTwice(this.spawnCommandStub);
sinon.assert.calledWithExactly(this.spawnCommandStub, 'bower', ['install'], {});
sinon.assert.calledWithExactly(this.spawnCommandStub, 'npm', ['install'], {});
sinon.assert.calledWithExactly(this.spawnCommandStub, 'npm', ['install', '--cache-min', 86400], {});
done();
}.bind(this));
this.dummy.run();
Expand Down

0 comments on commit 2c34bde

Please sign in to comment.