From b1635735caedeeece5d94ed2f1fc8c242ef958bb Mon Sep 17 00:00:00 2001 From: zkochan Date: Wed, 26 Apr 2017 14:49:17 +0300 Subject: [PATCH] fix: always-auth config value is not ignored anymore Ref #708 --- src/api/extendOptions.ts | 1 + src/api/install.ts | 1 + src/network/got.ts | 11 ++++++++--- src/types.ts | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/api/extendOptions.ts b/src/api/extendOptions.ts index fd282ccc69..36243070a8 100644 --- a/src/api/extendOptions.ts +++ b/src/api/extendOptions.ts @@ -34,6 +34,7 @@ const defaults = (opts: PnpmOptions) => { registry: 'https://registry.npmjs.org/', userAgent: `${pnpmPkgJson.name}/${pnpmPkgJson.version} npm/? node/${process.version} ${process.platform} ${process.arch}`, rawNpmConfig: {}, + alwaysAuth: false, } } diff --git a/src/api/install.ts b/src/api/install.ts index 33a8a432e2..996cf9beb9 100644 --- a/src/api/install.ts +++ b/src/api/install.ts @@ -201,6 +201,7 @@ async function installInContext ( got: createGot(client, { networkConcurrency: opts.networkConcurrency, rawNpmConfig: opts.rawNpmConfig, + alwaysAuth: opts.alwaysAuth, }), metaCache: opts.metaCache, resolvedDependencies, diff --git a/src/network/got.ts b/src/network/got.ts index 46f9ba0845..deff7d28df 100644 --- a/src/network/got.ts +++ b/src/network/got.ts @@ -8,11 +8,13 @@ import path = require('path') import createWriteStreamAtomic = require('fs-write-stream-atomic') export type AuthInfo = { - token: string + alwaysAuth: boolean, +} & ({ + token: string, } | { username: string, password: string, -} +}) export type HttpResponse = { body: string @@ -38,6 +40,7 @@ export default ( opts: { networkConcurrency: number, rawNpmConfig: Object, + alwaysAuth: boolean, } ): Got => { const limit = pLimit(opts.networkConcurrency) @@ -118,10 +121,12 @@ export default ( switch (authInfo.type) { case 'Bearer': return { - token: authInfo.token + alwaysAuth: opts.alwaysAuth, + token: authInfo.token, } case 'Basic': return { + alwaysAuth: opts.alwaysAuth, username: authInfo.username, password: authInfo.password, } diff --git a/src/types.ts b/src/types.ts index 6d44ef116b..d4365f6a4b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -44,6 +44,7 @@ export type PnpmOptions = { tag?: string, metaCache?: Map, + alwaysAuth?: boolean, } export type StrictPnpmOptions = { @@ -89,6 +90,7 @@ export type StrictPnpmOptions = { tag: string, metaCache: Map, + alwaysAuth: boolean, } export type Dependencies = {