Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions packages/next-codemod/bin/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export async function runUpgrade(

let shouldRunReactCodemods = false
let shouldRunReactTypesCodemods = false
let execCommand = 'npx'
let execCommand = 'npx --yes'
// The following React codemods are for React 19
if (
!shouldStayOnReact18 &&
Expand All @@ -213,13 +213,7 @@ export async function runUpgrade(
shouldRunReactCodemods = await suggestReactCodemods()
shouldRunReactTypesCodemods = await suggestReactTypesCodemods()

const execCommandMap = {
yarn: 'yarn dlx',
pnpm: 'pnpx',
bun: 'bunx',
npm: 'npx',
}
execCommand = execCommandMap[packageManager]
execCommand = getNpxCommand(packageManager)
}

fs.writeFileSync(appPackageJsonPath, JSON.stringify(appPackageJson, null, 2))
Expand Down Expand Up @@ -740,3 +734,19 @@ function warnDependenciesOutOfRange(
})
}
}

function getNpxCommand(pkgManager: PackageManager) {
let command = 'npx --yes'
if (pkgManager === 'pnpm') {
command = 'pnpm --silent dlx'
} else if (pkgManager === 'yarn') {
try {
execSync('yarn dlx --help', { stdio: 'ignore', cwd })
command = 'yarn --quiet dlx'
} catch {}
} else if (pkgManager === 'bun') {
command = 'bunx'
}

return command
}
Loading