From f4c55e2864aebd79ad345d62eddb5b3d51beb1cc Mon Sep 17 00:00:00 2001 From: Tony Kovanen Date: Fri, 15 Jul 2016 20:24:40 +0300 Subject: [PATCH] Forward registry auth token only if asked --- lib/index.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/index.js b/lib/index.js index c4c8b21..873101f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -64,21 +64,23 @@ export default class Now extends EventEmitter { } // Read .npmrc - let npmrc; - try { - npmrc = await readFile(resolvePath(path, '.npmrc'), 'utf8'); - npmrc = parseIni(npmrc); - } catch (err) { - // Do nothing - } - - if (!npmrc) { + let npmrc = {}; + if (pkg['forward-npm']) { try { - npmrc = await readFile(resolvePath(homedir(), '.npmrc'), 'utf8'); + npmrc = await readFile(resolvePath(path, '.npmrc'), 'utf8'); npmrc = parseIni(npmrc); } catch (err) { // Do nothing } + + if (!npmrc) { + try { + npmrc = await readFile(resolvePath(homedir(), '.npmrc'), 'utf8'); + npmrc = parseIni(npmrc); + } catch (err) { + // Do nothing + } + } } const authToken = npmrc['//registry.npmjs.org/:_authToken'];