mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-07 15:38:24 -04:00
14 lines
359 B
TypeScript
14 lines
359 B
TypeScript
import { Registries } from '@pnpm/types'
|
|
|
|
export default (registries: Registries, packageName: string) => {
|
|
const scope = getScope(packageName)
|
|
return scope && registries[scope] || registries.default
|
|
}
|
|
|
|
function getScope (pkgName: string): string | null {
|
|
if (pkgName[0] === '@') {
|
|
return pkgName.substr(0, pkgName.indexOf('/'))
|
|
}
|
|
return null
|
|
}
|