Skip to content

Commit

Permalink
fix(list): don't fail on local directory dependencies (#6911)
Browse files Browse the repository at this point in the history
close #6873
  • Loading branch information
zkochan committed Aug 5, 2023
1 parent 92f4222 commit aaefb07
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
5 changes: 4 additions & 1 deletion reviewing/dependencies-hierarchy/src/getPkgInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface GetPkgInfoOpts {

export function getPkgInfo (opts: GetPkgInfoOpts): PackageInfo {
let name!: string
let version!: string
let version: string
let resolved: string | undefined
let dev: boolean | undefined
let optional: true | undefined
Expand Down Expand Up @@ -73,6 +73,9 @@ export function getPkgInfo (opts: GetPkgInfoOpts): PackageInfo {
name = opts.alias
version = opts.ref
}
if (!version) {
version = opts.ref
}
const fullPackagePath = depPath
? path.join(opts.virtualStoreDir ?? '.pnpm', depPathToFilename(depPath), 'node_modules', name)
: path.join(opts.linkedPathBaseDir, opts.ref.slice(5))
Expand Down
34 changes: 34 additions & 0 deletions reviewing/plugin-commands-listing/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,37 @@ pkg-with-optional 1.0.0
└── not-compatible-with-any-os 1.0.0 skipped`)
}
})

// Covers https://github.com/pnpm/pnpm/issues/6873
test('listing packages should not fail on package that has local file directory in dependencies', async () => {
preparePackages([
{
name: 'dep',
version: '1.0.0',
},
{
name: 'pkg',
version: '1.0.0',

dependencies: {
dep: 'file:../dep',
},
},
])

const pkgDir = path.resolve('pkg')
await execa('node', [pnpmBin, 'install'], { cwd: pkgDir })

const output = await list.handler({
dev: false,
dir: pkgDir,
optional: false,
}, [])

expect(stripAnsi(output)).toBe(`Legend: production dependency, optional only, dev only
pkg@1.0.0 ${pkgDir}
dependencies:
dep file:../dep`)
})

0 comments on commit aaefb07

Please sign in to comment.