diff --git a/lib/actions/install.js b/lib/actions/install.js index ffcab212..630d581d 100644 --- a/lib/actions/install.js +++ b/lib/actions/install.js @@ -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]); @@ -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.' diff --git a/test/install.js b/test/install.js index 784badfc..fbf5454b 100644 --- a/test/install.js +++ b/test/install.js @@ -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();