Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Add yarn1 package manager fallback for init in empty directory #26500

Merged
merged 1 commit into from
Mar 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion code/lib/cli/src/initiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export async function doInitiate(
> {
const { packageManager: pkgMgr } = options;

const packageManager = JsPackageManagerFactory.getPackageManager({
let packageManager = JsPackageManagerFactory.getPackageManager({
force: pkgMgr,
});

Expand Down Expand Up @@ -276,6 +276,13 @@ export async function doInitiate(

// Check if the current directory is empty.
if (options.force !== true && currentDirectoryIsEmpty(packageManager.type)) {
// Initializing Storybook in an empty directory with yarn1
// will very likely fail due to different kind of hoisting issues
// which doesn't get fixed anymore in yarn1.
// We will fallback to npm in this case.
if (packageManager.type === 'yarn1') {
packageManager = JsPackageManagerFactory.getPackageManager({ force: 'npm' });
}
// Prompt the user to create a new project from our list.
await scaffoldNewProject(packageManager.type, options);

Expand Down