Skip to content

Commit 1626124

Browse files
committed
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.
1 parent 665792b commit 1626124

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Diff for: gulpfile.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,16 @@ gulp.task('installFixtures', function() {
148148
}, 1 * 1000);
149149
shell.cd('test/fixtures');
150150

151-
execAsync('npm install --quiet', {cwd: '../fixtures'}).then(() => {
151+
let installCommand;
152+
if(process.platform === 'win32') {
153+
installCommand = 'yarn --version >nul 2>&1 && ( yarn install ) || ( npm install --quiet )';
154+
} else {
155+
installCommand = 'type yarn &> /dev/null | yarn install || npm install --quiet';
156+
}
157+
158+
execAsync(installCommand, {
159+
cwd: '../fixtures'
160+
}).then(() => {
152161
process.stdout.write('\n');
153162
if(!process.env.SAUCE_USERNAME) {
154163
gutil.log('running npm run-script update-webdriver');

Diff for: src/generators/app/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,15 @@ export class Generator extends Base {
606606

607607
install() {
608608
if(!this.options['skip-install']) {
609-
this.spawnCommand('npm', ['install']);
609+
let yarnCheckCommand;
610+
if (process.platform === 'win32') {
611+
yarnCheckCommand = 'yarn --version >nul 2>&1';
612+
} else {
613+
yarnCheckCommand = 'type yarn &> /dev/null';
614+
}
615+
exec(yarnCheckCommand, (error, stdout, stderr) => {
616+
return this.spawnCommand((!error) ? 'yarn' : 'npm', ['install']);
617+
});
610618
}
611619
}
612620

0 commit comments

Comments
 (0)