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 <dsanders11@ucsbalum.com>
This commit is contained in:
seokju-na 2024-01-23 15:48:59 +09:00 коммит произвёл GitHub
Родитель 28714f9bcb
Коммит 38dcca2379
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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();