From 7ab8e0d344cef463048bc3444a6cf2aecc961514 Mon Sep 17 00:00:00 2001 From: Tony Kovanen Date: Sun, 17 Jul 2016 12:54:43 +0300 Subject: [PATCH] Add cmd line flag to forward NPM auth token --- bin/now-deploy | 9 ++++++--- lib/index.js | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bin/now-deploy b/bin/now-deploy index 22174ff..483fa06 100755 --- a/bin/now-deploy +++ b/bin/now-deploy @@ -14,7 +14,7 @@ import ms from 'ms'; import { handleError, error } from '../lib/error'; const argv = minimist(process.argv.slice(2), { - boolean: ['help', 'version', 'debug', 'force', 'login', 'no-clipboard'], + boolean: ['help', 'version', 'debug', 'force', 'login', 'no-clipboard', 'forward-npm'], alias: { help: 'h', debug: 'd', @@ -22,7 +22,8 @@ const argv = minimist(process.argv.slice(2), { force: 'f', forceSync: 'F', login: 'L', - 'no-clipboard': 'C' + 'no-clipboard': 'C', + 'forward-npm': 'N' } }); @@ -47,6 +48,7 @@ const help = () => { -f, --force force a new deployment even if nothing has changed -L, --login configure login -C, --no-clipboard do not attempt to copy URL to clipboard + -N, --forward-npm Forward login information to install private NPM modules ${chalk.dim('Examples:')} @@ -93,6 +95,7 @@ const exit = (code) => { // options const debug = argv.debug; const clipboard = !argv['no-clipboard']; +const forwardNpm = argv['forward-npm']; const force = argv.force; const forceSync = argv.forceSync; const shouldLogin = argv.login; @@ -138,7 +141,7 @@ async function sync (token) { const now = new Now(apiUrl, token, { debug }); try { - await now.create(path, { forceNew: force, forceSync: forceSync }); + await now.create(path, { forceNew: force, forceSync: forceSync, forwardNpm }); } catch (err) { handleError(err); process.exit(1); diff --git a/lib/index.js b/lib/index.js index 896aacc..571fcbd 100644 --- a/lib/index.js +++ b/lib/index.js @@ -30,7 +30,7 @@ export default class Now extends EventEmitter { this._onRetry = this._onRetry.bind(this); } - async create (path, { forceNew, forceSync }) { + async create (path, { forceNew, forceSync, forwardNpm }) { this._path = path; try { @@ -65,10 +65,12 @@ export default class Now extends EventEmitter { const nowProperties = pkg.now || {}; + forwardNpm = forwardNpm || nowProperties['forward-npm']; + // Read .npmrc let npmrc = {}; let authToken; - if (nowProperties['forward-npm']) { + if (forwardNpm) { try { npmrc = await readFile(resolvePath(path, '.npmrc'), 'utf8'); npmrc = parseIni(npmrc);