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

Don't use yarn if a package-lock.json file is found #31926

Merged
merged 3 commits into from Feb 5, 2022
Merged
Changes from 1 commit
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
11 changes: 9 additions & 2 deletions packages/next/lib/helpers/should-use-yarn.ts
@@ -1,13 +1,20 @@
import { execSync } from 'child_process'
import fs from 'fs'

export function shouldUseYarn(): boolean {
try {
const userAgent = process.env.npm_config_user_agent
if (userAgent) {
return Boolean(userAgent && userAgent.startsWith('yarn'))
} else {
if (fs.existsSync('yarn.lock')) {
thibautsabot marked this conversation as resolved.
Show resolved Hide resolved
ijjk marked this conversation as resolved.
Show resolved Hide resolved
return true
} else if (fs.existsSync('package-lock.json')) {
return false
}
execSync('yarnpkg --version', { stdio: 'ignore' })
return true
}
execSync('yarnpkg --version', { stdio: 'ignore' })
return true
} catch (e) {
return false
}
Expand Down