mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-04 13:31:19 +08:00
CLI: Add Yarn workspaces support for init command (#9104)
CLI: Add Yarn workspaces support for init command
This commit is contained in:
commit
5e7c040e1a
@ -23,7 +23,7 @@ See the command-line help with `-h` for details.
|
||||
|
||||
## [Yarn](https://github.com/yarnpkg/yarn) support
|
||||
|
||||
The CLI supports yarn. If you have installed yarn in your system, it'll detect it and use `yarn` instead of `npm`.
|
||||
The CLI supports yarn. If you have installed yarn in your system and your project has `yarn.lock` file, it'll detect it and use `yarn` instead of `npm`.
|
||||
|
||||
If you don't want to use `yarn` always you can use the `--use-npm` option like this:
|
||||
|
||||
|
@ -1,12 +1,15 @@
|
||||
import { sync as spawnSync } from 'cross-spawn';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import findUp from 'find-up';
|
||||
|
||||
export default function hasYarn() {
|
||||
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) {
|
||||
|
||||
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;
|
||||
|
@ -46,6 +46,7 @@
|
||||
"didyoumean": "^1.2.1",
|
||||
"envinfo": "^7.5.0",
|
||||
"esm": "3.2.25",
|
||||
"find-up": "^4.1.0",
|
||||
"fs-extra": "^8.0.1",
|
||||
"inquirer": "^7.0.0",
|
||||
"jscodeshift": "^0.6.3",
|
||||
|
Loading…
x
Reference in New Issue
Block a user