Unverified Commit 17010ae8 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[next-upgrade] Fall back to `npx` if `yarn dlx` is not available (#86384)

parent bb1a5728
......@@ -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 &&
......@@ -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))
......@@ -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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment