mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-06 23:19:19 -04:00
fix(config): @pnpm/config should always normalize registries
This commit is contained in:
@@ -2,8 +2,12 @@ export default function getScopeRegistries (rawNpmConfig: Object) {
|
||||
const registries = {}
|
||||
for (const configKey of Object.keys(rawNpmConfig)) {
|
||||
if (configKey[0] === '@' && configKey.endsWith(':registry')) {
|
||||
registries[configKey.substr(0, configKey.indexOf(':'))] = rawNpmConfig[configKey]
|
||||
registries[configKey.substr(0, configKey.indexOf(':'))] = normalizeRegistry(rawNpmConfig[configKey])
|
||||
}
|
||||
}
|
||||
return registries
|
||||
}
|
||||
|
||||
export function normalizeRegistry (registry: string) {
|
||||
return registry.endsWith('/') ? registry : `${registry}/`
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import camelcase from 'camelcase'
|
||||
import findUp = require('find-up')
|
||||
import path = require('path')
|
||||
import whichcb = require('which')
|
||||
import getScopeRegistries from './getScopeRegistries'
|
||||
import getScopeRegistries, { normalizeRegistry } from './getScopeRegistries'
|
||||
import { PnpmConfigs } from './PnpmConfigs'
|
||||
|
||||
export { PnpmConfigs }
|
||||
@@ -134,7 +134,7 @@ export default async (
|
||||
}, {} as PnpmConfigs)
|
||||
pnpmConfig.rawNpmConfig = Object.assign.apply(Object, npmConfig.list.reverse().concat([cliArgs]))
|
||||
pnpmConfig.registries = {
|
||||
default: pnpmConfig.registry || 'https://registry.npmjs.org/',
|
||||
default: normalizeRegistry(pnpmConfig.registry || 'https://registry.npmjs.org/'),
|
||||
...getScopeRegistries(pnpmConfig.rawNpmConfig),
|
||||
}
|
||||
const npmGlobalPrefix: string = pnpmConfig.rawNpmConfig['pnpm-prefix'] ||
|
||||
|
||||
@@ -158,11 +158,13 @@ test('registries of scoped packages are read', async (t) => {
|
||||
},
|
||||
})
|
||||
|
||||
// tslint:disable
|
||||
t.deepEqual(opts.registries, {
|
||||
'@bar': 'https://bar.com',
|
||||
'@foo': 'https://foo.com',
|
||||
'default': 'https://registry.npmjs.org/',
|
||||
'@foo': 'https://foo.com/',
|
||||
'@bar': 'https://bar.com/',
|
||||
})
|
||||
// tslint:enable
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
@@ -434,7 +434,7 @@ async function resolveDependency (
|
||||
}
|
||||
|
||||
const scope = wantedDependency.alias && getScope(wantedDependency.alias)
|
||||
const registry = normalizeRegistry(scope && ctx.registries[scope] || ctx.registries.default)
|
||||
const registry = scope && ctx.registries[scope] || ctx.registries.default
|
||||
|
||||
let pkgResponse!: PackageResponse
|
||||
try {
|
||||
@@ -736,11 +736,6 @@ function peerDependenciesWithoutOwn (pkg: PackageManifest) {
|
||||
return result
|
||||
}
|
||||
|
||||
function normalizeRegistry (registry: string) {
|
||||
if (registry.endsWith('/')) return registry
|
||||
return `${registry}/`
|
||||
}
|
||||
|
||||
async function resolveDependenciesOfPackage (
|
||||
pkg: PackageManifest,
|
||||
ctx: ResolutionContext,
|
||||
|
||||
Reference in New Issue
Block a user