mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-10 18:18:56 -04:00
feat(hooks): pass registries to preResolution hook (#6326)
This commit is contained in:
6
.changeset/forty-bears-smoke.md
Normal file
6
.changeset/forty-bears-smoke.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/core": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Registries are now passed to the preResolution hook.
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Lockfile } from '@pnpm/lockfile-file'
|
||||
import type { Registries } from '@pnpm/types'
|
||||
|
||||
export interface PreResolutionHookContext {
|
||||
wantedLockfile: Lockfile
|
||||
@@ -7,6 +8,7 @@ export interface PreResolutionHookContext {
|
||||
existsWantedLockfile: boolean
|
||||
lockfileDir: string
|
||||
storeDir: string
|
||||
registries: Registries
|
||||
}
|
||||
|
||||
export interface PreResolutionHookLogger {
|
||||
|
||||
@@ -239,6 +239,7 @@ export async function mutateModules (
|
||||
existsWantedLockfile: ctx.existsWantedLockfile,
|
||||
lockfileDir: ctx.lockfileDir,
|
||||
storeDir: ctx.storeDir,
|
||||
registries: ctx.registries,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -632,6 +632,7 @@ test('preResolution hook', async () => {
|
||||
|
||||
const npmrc = `
|
||||
global-pnpmfile=.pnpmfile.cjs
|
||||
@foo:registry=https://foo.com
|
||||
`
|
||||
|
||||
await fs.writeFile('.npmrc', npmrc, 'utf8')
|
||||
@@ -646,4 +647,9 @@ test('preResolution hook', async () => {
|
||||
expect(ctx.storeDir).toBeDefined()
|
||||
expect(ctx.existsCurrentLockfile).toBe(false)
|
||||
expect(ctx.existsWantedLockfile).toBe(false)
|
||||
|
||||
expect(ctx.registries).toEqual({
|
||||
default: 'http://localhost:7776/',
|
||||
'@foo': 'https://foo.com/',
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user