Browse Source

Add cmd line flag to forward NPM auth token

master
Tony Kovanen 9 years ago
parent
commit
7ab8e0d344
  1. 9
      bin/now-deploy
  2. 6
      lib/index.js

9
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);

6
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);

Loading…
Cancel
Save