mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-30 04:52:04 -04:00
fix(dependency-path): parsing a local dep
This commit is contained in:
5
.changeset/itchy-baboons-know.md
Normal file
5
.changeset/itchy-baboons-know.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/dependency-path": patch
|
||||
---
|
||||
|
||||
`parse()` should not fail on dependency path pointing to a local dependency.
|
||||
@@ -105,6 +105,10 @@ export function parse (dependencyPath: string) {
|
||||
const parts = dependencyPath.split('/')
|
||||
if (!_isAbsolute) parts.shift()
|
||||
const host = _isAbsolute ? parts.shift() : undefined
|
||||
if (parts.length === 0) return {
|
||||
host,
|
||||
isAbsolute: _isAbsolute,
|
||||
}
|
||||
const name = parts[0].startsWith('@')
|
||||
? `${parts.shift()}/${parts.shift()}` // eslint-disable-line @typescript-eslint/restrict-template-expressions
|
||||
: parts.shift()
|
||||
|
||||
@@ -99,6 +99,11 @@ test('parse()', () => {
|
||||
})
|
||||
|
||||
expect(() => parse('/foo/bar')).toThrow(/\/foo\/bar is an invalid relative dependency path/)
|
||||
|
||||
expect(parse('file:project(foo@1.0.0)')).toStrictEqual({
|
||||
host: 'file:project(foo@1.0.0)',
|
||||
isAbsolute: true,
|
||||
})
|
||||
})
|
||||
|
||||
test('refToAbsolute()', () => {
|
||||
|
||||
Reference in New Issue
Block a user