fix: show absolute path instead of ??? when globally linking from cwd (#10899)

When running `pnpm add -g .`, the linked-from path equals the cwd,
so path.relative() returns an empty string which is falsy, causing
the fallback to '???'. Use the absolute path as fallback instead.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Zoltan Kochan
2026-03-07 15:49:20 +01:00
committed by GitHub
parent 1ec944a31b
commit c096e48090
2 changed files with 7 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/default-reporter": patch
"pnpm": patch
---
Fixed global install output showing `???` instead of the linked package path when linking from the current directory.

View File

@@ -118,7 +118,7 @@ function printDiffs (
result += ` ${chalk.red('deprecated')}`
}
if (pkg.from) {
result += ` ${chalk.grey(`<- ${pkg.from && path.relative(opts.prefix, pkg.from) || '???'}`)}`
result += ` ${chalk.grey(`<- ${path.relative(opts.prefix, pkg.from) || pkg.from}`)}`
}
if (pkg.added && depType === 'dev' && opts.pnpmConfig?.saveDev === false && opts.cmd === 'add') {
result += `${chalk.yellow(' already in devDependencies, was not moved to dependencies.')}`