Skip to content

Commit

Permalink
feat: add support for pnpm workspace (#1027)
Browse files Browse the repository at this point in the history
* Add pnpm workspace support

* Update comments

* chore: correct filename for pnpm lockfile

* chore: correct filename for pnpm lockfile

---------

Co-authored-by: David Sanders <[email protected]>
  • Loading branch information
seokju-na and dsanders11 authored Jan 23, 2024
1 parent 28714f9 commit 38dcca2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/search-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
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) {
Expand Down
2 changes: 1 addition & 1 deletion test/search-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function removeTempDir(): Promise<void> {
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();
Expand Down

0 comments on commit 38dcca2

Please sign in to comment.