Skip to content

Commit

Permalink
Fix yarnInstall to add new package - Fix #980
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Nov 26, 2016
1 parent cd5e34d commit bddb942
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/actions/install.js
Expand Up @@ -35,6 +35,11 @@ install.runInstall = function (installer, paths, options, cb) {

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

// Yarn uses the `add` command to specifically add a package to a project.
if (installer === 'yarn' && paths.length > 0) {
args[0] = 'add';
}

// only for npm, use a minimum cache of one day
if (installer === 'npm') {
args = args.concat(['--cache-min', 24 * 60 * 60]);
Expand All @@ -49,7 +54,7 @@ install.runInstall = function (installer, paths, options, cb) {
this.env.runLoop.add('install', function (done) {
this.emit(installer + 'Install', paths);
this.spawnCommand(installer, args, options)
.on('error', function (err){
.on('error', function (err) {
console.log(chalk.red('Could not finish installation. \n') +
'Please install ' + installer + ' with ' +
chalk.yellow('npm install -g ' + installer) + ' and try again.'
Expand Down
6 changes: 4 additions & 2 deletions test/install.js
Expand Up @@ -164,16 +164,18 @@ describe('Base (actions/install mixin)', function () {
});

it('run without callback', function (done) {
this.dummy.yarnInstall('yo', { save: true });
this.dummy.yarnInstall('yo', {dev: true});
this.dummy.run(function () {
sinon.assert.calledOnce(this.spawnCommandStub);
sinon.assert.calledWithExactly(this.spawnCommandStub, 'yarn', ['add', 'yo', '--dev'], {dev: true});
done();
}.bind(this));
});

it('run with callback', function (done) {
this.dummy.yarnInstall('yo', { save: true }, function () {
this.dummy.yarnInstall('yo', function () {
sinon.assert.calledOnce(this.spawnCommandStub);
sinon.assert.calledWithExactly(this.spawnCommandStub, 'yarn', ['add', 'yo'], {});
done();
}.bind(this));
this.dummy.run();
Expand Down

0 comments on commit bddb942

Please sign in to comment.