1
0
mirror of https://github.com/storybookjs/storybook.git synced 2025-04-05 06:51:25 +08:00

17 lines
549 B
JavaScript

import { sync as spawnSync } from 'cross-spawn';
import path from 'path';
import findUp from 'find-up';
export function hasYarn() {
const yarnAvailable = spawnSync('yarn', ['--version'], { silent: true });
const npmAvailable = spawnSync('npm', ['--version'], { silent: true });
const lockFile = findUp.sync(['yarn.lock', 'package-lock.json']);
const hasYarnLock = lockFile && path.basename(lockFile) === 'yarn.lock';
if (yarnAvailable.status === 0 && (hasYarnLock || npmAvailable.status !== 0)) {
return true;
}
return false;
}