Skip to content

Commit

Permalink
Skip any install script when --skip-install is passed
Browse files Browse the repository at this point in the history
Fix #745
  • Loading branch information
SBoudrias committed Mar 30, 2015
1 parent 1d6db5a commit 9ff2988
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
10 changes: 6 additions & 4 deletions lib/actions/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ install.runInstall = function (installer, paths, options, cb) {

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

// Return early if we're skipping installation.
if (this.options.skipInstall) {
cb();
return this;
}

this.env.runLoop.add('install', function (done) {
this.emit(installer + 'Install', paths);
this.spawnCommand(installer, args, options)
Expand Down Expand Up @@ -123,10 +129,6 @@ install.installDependencies = function (options) {
})));
}

if (options.skipInstall) {
return options.callback();
}

async.parallel(commands, options.callback);
};

Expand Down
40 changes: 27 additions & 13 deletions test/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,33 @@ describe('generators.Base (actions/install mixin)', function () {
done();
}.bind(this));
});

describe('with --skip-install', function () {
beforeEach(function () {
this.dummy = this.env.create('dummy', {
options: {
skipInstall: true
}
});
});

it('does not spawn anything with skipInstall', function (done) {
this.dummy.runInstall('npm', ['install']);
this.dummy.run(function () {
sinon.assert.notCalled(this.spawnCommandStub);
done();
}.bind(this));
});

it('call callback if skipInstall', function (done) {
var spy = sinon.spy();
this.dummy.runInstall('npm', ['install'], spy);
this.dummy.run(function () {
sinon.assert.calledOnce(spy);
done();
});
});
});
});

describe('#bowerInstall()', function () {
Expand Down Expand Up @@ -114,19 +141,6 @@ describe('generators.Base (actions/install mixin)', function () {
this.dummy.run();
});

it('does not spawn anything with skipInstall', function (done) {
this.dummy.installDependencies({ skipInstall: true });
this.dummy.run(function () {
sinon.assert.notCalled(this.spawnCommandStub);
done();
}.bind(this));
});

it('call callback if skipInstall', function (done) {
this.dummy.installDependencies({ skipInstall: true, callback: done });
this.dummy.run();
});

it('execute a callback after installs', function (done) {
this.dummy.installDependencies({ callback: done });
this.dummy.run();
Expand Down

0 comments on commit 9ff2988

Please sign in to comment.