Skip to content

Commit

Permalink
use baseDir to find lock files
Browse files Browse the repository at this point in the history
  • Loading branch information
thibautsabot committed Nov 29, 2021
1 parent 5f7ea0d commit 6472406
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions packages/next/lib/helpers/should-use-yarn.ts
@@ -1,15 +1,16 @@
import { execSync } from 'child_process'
import fs from 'fs'
import path from 'path'

export function shouldUseYarn(): boolean {
export function shouldUseYarn(baseDir: string): boolean {
try {
const userAgent = process.env.npm_config_user_agent
if (userAgent) {
return Boolean(userAgent && userAgent.startsWith('yarn'))
} else {
if (fs.existsSync('yarn.lock')) {
if (fs.existsSync(path.join(baseDir, 'yarn.lock'))) {
return true
} else if (fs.existsSync('package-lock.json')) {
} else if (fs.existsSync(path.join(baseDir, 'package-lock.json'))) {
return false
}
execSync('yarnpkg --version', { stdio: 'ignore' })
Expand Down
2 changes: 1 addition & 1 deletion packages/next/lib/install-dependencies.ts
Expand Up @@ -15,7 +15,7 @@ export async function installDependencies(
deps: any,
dev: boolean = false
) {
const useYarn = shouldUseYarn()
const useYarn = shouldUseYarn(baseDir)
const isOnline = !useYarn || (await getOnline())

if (deps.length) {
Expand Down

0 comments on commit 6472406

Please sign in to comment.