Skip to content

Commit

Permalink
Merge pull request #3453 from Keraito/detect-yarn-lock
Browse files Browse the repository at this point in the history
Change yarn detection
  • Loading branch information
Hypnosphi committed Apr 27, 2018
1 parent 8984572 commit dab6b17
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/cli/lib/has_yarn.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { sync as spawnSync } from 'cross-spawn';
import path from 'path';
import fs from 'fs';

export default function hasYarn() {
const result = spawnSync('yarn', ['--version'], { silent: true });
return result.status === 0;
const yarnAvailable = spawnSync('yarn', ['--version'], { silent: true });
const npmAvailable = spawnSync('npm', ['--version'], { silent: true });
const yarnLockPath = path.resolve('yarn.lock');
if ((fs.existsSync(yarnLockPath) || npmAvailable.status !== 0) && yarnAvailable.status === 0) {
return true;
}
return false;
}

0 comments on commit dab6b17

Please sign in to comment.