diff --git a/src/npm.ts b/src/npm.ts index 55c25763..46b0d0a7 100644 --- a/src/npm.ts +++ b/src/npm.ts @@ -184,8 +184,7 @@ async function getYarnProductionDependencies(root: string, manifest: Manifest, p return result; } -async function getYarnDependencies(cwd: string, manifest: Manifest, packagedDependencies?: string[]): Promise { - const root = findWorkspaceRoot(cwd) || cwd; +async function getYarnDependencies(cwd: string, root: string, manifest: Manifest, packagedDependencies?: string[]): Promise { const result: SourceAndDestination[] = [{ src: cwd, dest: '' @@ -203,9 +202,9 @@ async function getYarnDependencies(cwd: string, manifest: Manifest, packagedDepe return _.uniqBy(result, 'src'); } -export async function detectYarn(cwd: string) { +export async function detectYarn(root: string) { for (const file of ['yarn.lock', '.yarnrc']) { - if (await exists(path.join(cwd, file))) { + if (await exists(path.join(root, file))) { if (!process.env['VSCE_TESTS']) { log.info( `Detected presence of ${file}. Using 'yarn' instead of 'npm' (to override this pass '--no-yarn' on the command line).` @@ -223,8 +222,9 @@ export async function getDependencies( useYarn?: boolean, packagedDependencies?: string[] ): Promise { - return (useYarn !== undefined ? useYarn : await detectYarn(cwd)) - ? await getYarnDependencies(cwd, manifest, packagedDependencies) + const root = findWorkspaceRoot(cwd) || cwd; + return (useYarn !== undefined ? useYarn : await detectYarn(root)) + ? await getYarnDependencies(cwd, root, manifest, packagedDependencies) : await getNpmDependencies(cwd); } diff --git a/src/test/package.test.ts b/src/test/package.test.ts index 60112462..130f278d 100644 --- a/src/test/package.test.ts +++ b/src/test/package.test.ts @@ -263,7 +263,7 @@ describe('collect', function () { assert.equal(manifest.name, 'package-b'); - const files = await collect(manifest, { cwd, useYarn: true }) as ILocalFile[]; + const files = await collect(manifest, { cwd }) as ILocalFile[]; [ {