From 38dcca23793c75fe83b7fe4284acf0fa62fddcdf Mon Sep 17 00:00:00 2001 From: seokju-na Date: Tue, 23 Jan 2024 15:48:59 +0900 Subject: [PATCH] feat: add support for pnpm workspace (#1027) * Add pnpm workspace support * Update comments * chore: correct filename for pnpm lockfile * chore: correct filename for pnpm lockfile --------- Co-authored-by: David Sanders --- src/search-module.ts | 4 ++-- test/search-module.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/search-module.ts b/src/search-module.ts index 0158b44f..a9df2196 100644 --- a/src/search-module.ts +++ b/src/search-module.ts @@ -69,12 +69,12 @@ export async function searchForNodeModules(cwd: string, rootPath?: string): Prom /** * Determine the root directory of a given project, by looking for a directory with an - * NPM or yarn lockfile. + * NPM or yarn lockfile or pnpm lockfile. * * @param cwd the initial directory to traverse */ export async function getProjectRootPath(cwd: string): Promise { - for (const lockFilename of ['yarn.lock', 'package-lock.json']) { + for (const lockFilename of ['yarn.lock', 'package-lock.json', 'pnpm-lock.yaml']) { const pathGenerator: PathGeneratorFunction = (traversedPath) => path.join(traversedPath, lockFilename); const lockPaths = await traverseAncestorDirectories(cwd, pathGenerator, undefined, 1) if (lockPaths.length > 0) { diff --git a/test/search-module.ts b/test/search-module.ts index 3aad3880..8172bdf1 100644 --- a/test/search-module.ts +++ b/test/search-module.ts @@ -18,7 +18,7 @@ async function removeTempDir(): Promise { describe('search-module', () => { describe('getProjectRootPath', () => { describe('multi-level workspace', () => { - for (const lockFile of ['yarn.lock', 'package-lock.json']) { + for (const lockFile of ['yarn.lock', 'package-lock.json', 'pnpm-lock.yaml']) { describe(lockFile, () => { before(async () => { await createTempDir();