From d9564e35468b6cc6f9302eeb3f0eaeb580daab80 Mon Sep 17 00:00:00 2001 From: Michel TURPIN Date: Tue, 9 Jan 2024 00:52:06 +0100 Subject: [PATCH] fix: use real path for module root dir (#6524) (#7491) close #6524 --- .changeset/real-knives-bathe.md | 7 +++++++ config/config/src/index.ts | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/real-knives-bathe.md diff --git a/.changeset/real-knives-bathe.md b/.changeset/real-knives-bathe.md new file mode 100644 index 00000000000..6b497167543 --- /dev/null +++ b/.changeset/real-knives-bathe.md @@ -0,0 +1,7 @@ +--- +"@pnpm/config": patch +"pnpm": patch +--- + +Resolve the current working directory to its real location before doing any operations [#6524](https://github.com/pnpm/pnpm/issues/6524). + diff --git a/config/config/src/index.ts b/config/config/src/index.ts index cde1899c38b..a456d00dcd6 100644 --- a/config/config/src/index.ts +++ b/config/config/src/index.ts @@ -291,7 +291,9 @@ export async function getConfig ( ...rcOptions.map((configKey) => [camelcase(configKey), npmConfig.get(configKey)]) as any, // eslint-disable-line ...Object.entries(cliOptions).filter(([name, value]) => typeof value !== 'undefined').map(([name, value]) => [camelcase(name), value]), ]) as unknown as ConfigWithDeprecatedSettings - const cwd = betterPathResolve(cliOptions.dir ?? npmConfig.localPrefix) + // Resolving the current working directory to its actual location is crucial. + // This prevents potential inconsistencies in the future, especially when processing or mapping subdirectories. + const cwd = fs.realpathSync(betterPathResolve(cliOptions.dir ?? npmConfig.localPrefix)) pnpmConfig.maxSockets = npmConfig.maxsockets // @ts-expect-error