mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-28 12:01:37 -04:00
@@ -31,7 +31,7 @@ export type Got = {
|
||||
onProgress?: (downloaded: number, totalSize: number) => void,
|
||||
integrity?: string
|
||||
}): Promise<{}>,
|
||||
getJSON<T>(url: string): Promise<T>,
|
||||
getJSON<T>(url: string, registry: string): Promise<T>,
|
||||
}
|
||||
|
||||
export type NpmRegistryClient = {
|
||||
@@ -58,10 +58,10 @@ export default (
|
||||
|
||||
const limit = pLimit(opts.networkConcurrency)
|
||||
|
||||
async function getJSON (url: string) {
|
||||
async function getJSON (url: string, registry: string) {
|
||||
return limit(() => new Promise((resolve, reject) => {
|
||||
const getOpts = {
|
||||
auth: getCredentialsByURI(url),
|
||||
auth: getCredentialsByURI(registry),
|
||||
fullMetadata: false,
|
||||
}
|
||||
client.get(url, getOpts, (err: Error, data: Object, raw: Object, res: HttpResponse) => {
|
||||
@@ -81,7 +81,7 @@ export default (
|
||||
return limit(async () => {
|
||||
await mkdirp(path.dirname(saveto))
|
||||
|
||||
const auth = getCredentialsByURI(opts.registry || url)
|
||||
const auth = opts.registry && getCredentialsByURI(opts.registry)
|
||||
// If a tarball is hosted on a different place than the manifest, only send
|
||||
// credentials on `alwaysAuth`
|
||||
const shouldAuth = auth && (
|
||||
|
||||
@@ -110,7 +110,8 @@ async function tryResolveViaGitHubApi (
|
||||
'commits',
|
||||
spec.ref
|
||||
].join('/')
|
||||
const body = await got.getJSON<GitHubRepoResponse>(url)
|
||||
// TODO: investigate what should be the correct registry path here
|
||||
const body = await got.getJSON<GitHubRepoResponse>(url, url)
|
||||
return body.sha
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ export default async function loadPkgMetaNonCached (
|
||||
|
||||
async function fromRegistry (got: Got, spec: PackageSpec, registry: string) {
|
||||
const uri = toUri(spec, registry)
|
||||
const meta = <PackageMeta>await got.getJSON(uri)
|
||||
const meta = <PackageMeta>await got.getJSON(uri, registry)
|
||||
return meta
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user