mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-25 10:31:55 -04:00
fix(shrinkwrap): save non-default registries in resolution field
This commit is contained in:
@@ -179,16 +179,19 @@ function toShrResolution (
|
||||
if (dp.isAbsolute(relDepPath) || resolution.type !== undefined || !resolution['integrity']) {
|
||||
return resolution as ShrinkwrapResolution
|
||||
}
|
||||
const base = registry !== resolution['registry'] ? {registry: resolution['registry']} : {}
|
||||
// Sometimes packages are hosted under non-standard tarball URLs.
|
||||
// For instance, when they are hosted on npm Enterprise. See https://github.com/pnpm/pnpm/issues/867
|
||||
// Or in othere weird cases, like https://github.com/pnpm/pnpm/issues/1072
|
||||
if (getNpmTarballUrl(pkg.name, pkg.version, {registry}) !== resolution['tarball']) {
|
||||
return {
|
||||
...base,
|
||||
integrity: resolution['integrity'],
|
||||
tarball: relativeTarball(resolution['tarball'], registry),
|
||||
}
|
||||
}
|
||||
return {
|
||||
...base,
|
||||
integrity: resolution['integrity'],
|
||||
}
|
||||
// tslint:enable:no-string-literal
|
||||
|
||||
@@ -844,3 +844,19 @@ test('save tarball URL when it is non-standard', async (t: tape.Test) => {
|
||||
|
||||
t.equal(shr.packages['/esprima-fb/3001.1.0-dev-harmony-fb'].resolution.tarball, '/esprima-fb/-/esprima-fb-3001.0001.0000-dev-harmony-fb.tgz')
|
||||
})
|
||||
|
||||
test('when package registry differs from default one, save it to resolution field', async (t: tape.Test) => {
|
||||
const project = prepare(t)
|
||||
|
||||
await installPkgs(['@zkochan/git-config', 'is-positive'], await testDefaults({
|
||||
rawNpmConfig: {
|
||||
'@zkochan:registry': 'https://registry.node-modules.io/',
|
||||
'registry': 'https://registry.npmjs.org/',
|
||||
},
|
||||
registry: 'https://registry.npmjs.org/',
|
||||
}))
|
||||
|
||||
const shr = await project.loadShrinkwrap()
|
||||
|
||||
t.equal(shr.packages['/@zkochan/git-config/0.1.0'].resolution.registry, 'https://registry.node-modules.io/')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user