From bea9570f608f62ad06b7195bd4a6f764d4f360e0 Mon Sep 17 00:00:00 2001 From: Thibaut Sabot Date: Mon, 29 Nov 2021 16:06:34 +0100 Subject: [PATCH] use baseDir to file lock files --- packages/next/lib/helpers/should-use-yarn.ts | 7 ++++--- packages/next/lib/install-dependencies.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/next/lib/helpers/should-use-yarn.ts b/packages/next/lib/helpers/should-use-yarn.ts index 5f5018c0dbc5f77..27c15b1dbac7da2 100644 --- a/packages/next/lib/helpers/should-use-yarn.ts +++ b/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' }) diff --git a/packages/next/lib/install-dependencies.ts b/packages/next/lib/install-dependencies.ts index 79184113e14f87b..a27133b472c6db6 100644 --- a/packages/next/lib/install-dependencies.ts +++ b/packages/next/lib/install-dependencies.ts @@ -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) {