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 '); },