From e122144065ab7674fe2512700d71c032b0056479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=EC=A7=84=EC=9A=B0?= Date: Thu, 6 Feb 2025 14:08:18 +0900 Subject: [PATCH] use dir not cwd --- packages/knip/src/manifest/helpers.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/knip/src/manifest/helpers.ts b/packages/knip/src/manifest/helpers.ts index 0dcb4b5d0..cac9b2a9c 100644 --- a/packages/knip/src/manifest/helpers.ts +++ b/packages/knip/src/manifest/helpers.ts @@ -4,7 +4,7 @@ import { dirname, join } from '../util/path.js'; import { _require } from '../util/require.js'; const pnpStatus = { - cwd: '', + dir: '', enabled: false, }; @@ -28,22 +28,22 @@ const findNearestPnPFile = (startDir: string): string | null => { return null; }; -const tryLoadManifestWithYarnPnp = (cwd: string, packageName: string) => { - if (pnpStatus.cwd === cwd && pnpStatus.enabled === false) { +const tryLoadManifestWithYarnPnp = (dir: string, packageName: string) => { + if (pnpStatus.dir === dir && pnpStatus.enabled === false) { return null; } try { - if (pnpStatus.cwd !== cwd) { - const pnpPath = findNearestPnPFile(cwd); + if (pnpStatus.dir !== dir) { + const pnpPath = findNearestPnPFile(dir); if (pnpPath != null) { const pnp = _require(pnpPath); pnp.setup(); - pnpStatus.cwd = cwd; + pnpStatus.dir = dir; pnpStatus.enabled = true; } else { - pnpStatus.cwd = cwd; + pnpStatus.dir = dir; pnpStatus.enabled = false; } } @@ -52,7 +52,7 @@ const tryLoadManifestWithYarnPnp = (cwd: string, packageName: string) => { const pnpApi = _require('pnpapi'); if (pnpApi != null) { - const resolvedPath = pnpApi.resolveRequest(packageName, cwd); + const resolvedPath = pnpApi.resolveRequest(packageName, dir); if (resolvedPath) { const packageLocation = pnpApi.findPackageLocator(resolvedPath); @@ -76,7 +76,7 @@ const tryLoadManifestWithYarnPnp = (cwd: string, packageName: string) => { export const loadPackageManifest = ({ dir, packageName, cwd }: LoadPackageManifestOptions) => { // 1. Try Yarn PnP first - const manifest = tryLoadManifestWithYarnPnp(cwd, packageName); + const manifest = tryLoadManifestWithYarnPnp(dir, packageName); if (manifest != null) { return manifest;