From 70073ca03267a12d02701755acdf4fc71bc6ceba Mon Sep 17 00:00:00 2001 From: Aman Varshney Date: Tue, 24 Mar 2026 02:29:55 +0530 Subject: [PATCH] fix: strip -y flag from npm init before package manager conversion npm-to-yarn converts `npm init -y` to `pnpm init -y` and `bun init -y`, but neither pnpm nor bun support the -y flag for init (they're always non-interactive). Strip -y before conversion so all package managers get a clean `init` command. --- apps/blog/source.config.ts | 8 ++++---- apps/docs/source.config.ts | 2 +- apps/eclipse/source.config.ts | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/blog/source.config.ts b/apps/blog/source.config.ts index cbc546dac0..afc9a15bc5 100644 --- a/apps/blog/source.config.ts +++ b/apps/blog/source.config.ts @@ -67,12 +67,12 @@ export default defineConfig({ persist: { id: "package-manager" }, // Custom package managers to add --bun flag for bunx commands packageManagers: [ - { command: (cmd: string) => convert(cmd, "npm"), name: "npm" }, - { command: (cmd: string) => convert(cmd, "pnpm"), name: "pnpm" }, - { command: (cmd: string) => convert(cmd, "yarn"), name: "yarn" }, + { command: (cmd: string) => convert(cmd.replace(/^npm init -y$/, "npm init"), "npm"), name: "npm" }, + { command: (cmd: string) => convert(cmd.replace(/^npm init -y$/, "npm init"), "pnpm"), name: "pnpm" }, + { command: (cmd: string) => convert(cmd.replace(/^npm init -y$/, "npm init"), "yarn"), name: "yarn" }, { command: (cmd: string) => { - const converted = convert(cmd, "bun"); + const converted = convert(cmd.replace(/^npm init -y$/, "npm init"), "bun"); if (!converted) return undefined; return converted.replace(/^bun x /, "bunx --bun "); }, diff --git a/apps/docs/source.config.ts b/apps/docs/source.config.ts index 6c27eb2197..f20b0df53c 100644 --- a/apps/docs/source.config.ts +++ b/apps/docs/source.config.ts @@ -19,7 +19,7 @@ import convert from "npm-to-yarn"; function convertLine(cmd: string, pm: "npm" | "pnpm" | "yarn" | "bun"): string { return cmd .split("\n") - .map((line) => convert(line, pm)) + .map((line) => convert(line.replace(/^npm init -y$/, "npm init"), pm)) .join("\n"); } diff --git a/apps/eclipse/source.config.ts b/apps/eclipse/source.config.ts index 3806a55cd2..f987df7694 100644 --- a/apps/eclipse/source.config.ts +++ b/apps/eclipse/source.config.ts @@ -47,12 +47,12 @@ export default defineConfig({ }, // Custom package managers to add --bun flag for bunx commands packageManagers: [ - { command: (cmd: string) => convert(cmd, 'npm'), name: 'npm' }, - { command: (cmd: string) => convert(cmd, 'pnpm'), name: 'pnpm' }, - { command: (cmd: string) => convert(cmd, 'yarn'), name: 'yarn' }, + { command: (cmd: string) => convert(cmd.replace(/^npm init -y$/, 'npm init'), 'npm'), name: 'npm' }, + { command: (cmd: string) => convert(cmd.replace(/^npm init -y$/, 'npm init'), 'pnpm'), name: 'pnpm' }, + { command: (cmd: string) => convert(cmd.replace(/^npm init -y$/, 'npm init'), 'yarn'), name: 'yarn' }, { command: (cmd: string) => { - const converted = convert(cmd, 'bun'); + const converted = convert(cmd.replace(/^npm init -y$/, 'npm init'), 'bun'); if (!converted) return undefined; return converted.replace(/^bun x /, 'bunx --bun '); },