mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-27 10:30:58 -04:00
fix: it should possible to use abolute file paths in overrides (#5757)
close #5754
This commit is contained in:
6
.changeset/perfect-islands-trade.md
Normal file
6
.changeset/perfect-islands-trade.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/hooks.read-package-hook": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
It should be possible to use overrides with absolute file paths [#5754](https://github.com/pnpm/pnpm/issues/5754).
|
||||
@@ -18,7 +18,8 @@ export function createVersionsOverrider (
|
||||
}
|
||||
let linkFileTarget: string | undefined
|
||||
if (override.newPref.startsWith('file:')) {
|
||||
linkFileTarget = path.join(rootDir, override.newPref.substring(5))
|
||||
const pkgPath = override.newPref.substring(5)
|
||||
linkFileTarget = path.isAbsolute(pkgPath) ? pkgPath : path.join(rootDir, pkgPath)
|
||||
}
|
||||
return {
|
||||
...override,
|
||||
|
||||
@@ -271,3 +271,23 @@ test('createVersionsOverrider() overrides dependencies with file', () => {
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test('createVersionsOverrider() overrides dependencies with file specified with absolute path', () => {
|
||||
const absolutePath = path.join(__dirname, 'qar')
|
||||
const overrider = createVersionsOverrider({
|
||||
qar: `file:${absolutePath}`,
|
||||
}, process.cwd())
|
||||
expect(overrider({
|
||||
name: 'foo',
|
||||
version: '1.2.0',
|
||||
dependencies: {
|
||||
qar: '3.0.0',
|
||||
},
|
||||
}, path.resolve('pkg'))).toStrictEqual({
|
||||
name: 'foo',
|
||||
version: '1.2.0',
|
||||
dependencies: {
|
||||
qar: `file:${absolutePath}`,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user