mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-27 10:30:58 -04:00
fix: path the project directory to the readPackage hook (#5475)
close #5443
This commit is contained in:
5
.changeset/great-dolls-collect.md
Normal file
5
.changeset/great-dolls-collect.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/hooks.read-package-hook": patch
|
||||
---
|
||||
|
||||
The readPackageHooks should always get the project directory as the second argument.
|
||||
5
.changeset/kind-bottles-knock.md
Normal file
5
.changeset/kind-bottles-knock.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
It should be possible to override dependencies with local packages using overrides [#5443](https://github.com/pnpm/pnpm/issues/5443).
|
||||
@@ -61,6 +61,6 @@ export function createReadPackageHook (
|
||||
}
|
||||
const readPackageAndExtend = hooks.length === 1
|
||||
? hooks[0]
|
||||
: ((pkg: PackageManifest | ProjectManifest, dir: string) => pipeWith(async (f, res) => f(await res, dir), hooks as any)(pkg)) as ReadPackageHook // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
: ((pkg: PackageManifest | ProjectManifest, dir: string) => pipeWith(async (f, res) => f(await res, dir), hooks as any)(pkg, dir)) as ReadPackageHook // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
return readPackageAndExtend
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { createReadPackageHook } from '../lib/createReadPackageHook'
|
||||
|
||||
test('createReadPackageHook() is passing directory to all hooks', async () => {
|
||||
const hook1 = jest.fn((manifest) => manifest)
|
||||
const hook2 = jest.fn((manifest) => manifest)
|
||||
const readPackageHook = createReadPackageHook({
|
||||
ignoreCompatibilityDb: true,
|
||||
lockfileDir: '/foo',
|
||||
readPackageHook: [hook1, hook2],
|
||||
})
|
||||
const manifest = {}
|
||||
const dir = '/bar'
|
||||
await readPackageHook!(manifest, dir)
|
||||
expect(hook1).toBeCalledWith(manifest, dir)
|
||||
expect(hook2).toBeCalledWith(manifest, dir)
|
||||
})
|
||||
Reference in New Issue
Block a user