mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-05 06:01:22 +08:00
26 lines
840 B
TypeScript
26 lines
840 B
TypeScript
import { join } from 'path';
|
|
import { move, remove } from 'fs-extra';
|
|
import { runCommand } from '../index';
|
|
|
|
interface SetupYarnOptions {
|
|
cwd: string;
|
|
pnp?: boolean;
|
|
version?: 'berry' | 'classic';
|
|
}
|
|
|
|
export async function setupYarn({ cwd, pnp = false, version = 'classic' }: SetupYarnOptions) {
|
|
await runCommand(`yarn set version ${version}`, { cwd });
|
|
if (version === 'berry' && !pnp) {
|
|
await runCommand('yarn config set nodeLinker node-modules', { cwd });
|
|
}
|
|
await remove(join(cwd, 'package.json'));
|
|
}
|
|
|
|
export async function localizeYarnConfigFiles(baseDir: string, beforeDir: string) {
|
|
await Promise.allSettled([
|
|
move(join(baseDir, '.yarn'), join(beforeDir, '.yarn')),
|
|
move(join(baseDir, '.yarnrc.yml'), join(beforeDir, '.yarnrc.yml')),
|
|
move(join(baseDir, '.yarnrc'), join(beforeDir, '.yarnrc')),
|
|
]);
|
|
}
|