From 162612495ad4ddb6b25b0e015992d4590cf00d57 Mon Sep 17 00:00:00 2001 From: Ben Marten Date: Fri, 7 Apr 2017 14:11:20 -0700 Subject: [PATCH] build(compile): adds support for yarn install checks if yarn is available and runs yarn install on setup. falls back to npm if yarn is not installed. --- gulpfile.js | 11 ++++++++++- src/generators/app/index.js | 10 +++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 768e6d419..f9afc6d36 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -148,7 +148,16 @@ gulp.task('installFixtures', function() { }, 1 * 1000); shell.cd('test/fixtures'); - execAsync('npm install --quiet', {cwd: '../fixtures'}).then(() => { + let installCommand; + if(process.platform === 'win32') { + installCommand = 'yarn --version >nul 2>&1 && ( yarn install ) || ( npm install --quiet )'; + } else { + installCommand = 'type yarn &> /dev/null | yarn install || npm install --quiet'; + } + + execAsync(installCommand, { + cwd: '../fixtures' + }).then(() => { process.stdout.write('\n'); if(!process.env.SAUCE_USERNAME) { gutil.log('running npm run-script update-webdriver'); diff --git a/src/generators/app/index.js b/src/generators/app/index.js index fe914e588..9c169d0ce 100644 --- a/src/generators/app/index.js +++ b/src/generators/app/index.js @@ -606,7 +606,15 @@ export class Generator extends Base { install() { if(!this.options['skip-install']) { - this.spawnCommand('npm', ['install']); + let yarnCheckCommand; + if (process.platform === 'win32') { + yarnCheckCommand = 'yarn --version >nul 2>&1'; + } else { + yarnCheckCommand = 'type yarn &> /dev/null'; + } + exec(yarnCheckCommand, (error, stdout, stderr) => { + return this.spawnCommand((!error) ? 'yarn' : 'npm', ['install']); + }); } }