From afc329a61c0bade5e3b98b4f51b4de67bc5e6a22 Mon Sep 17 00:00:00 2001 From: Luke Morton Date: Sat, 7 Jan 2017 06:57:41 +0000 Subject: [PATCH] Multiple aliases during deploy (#202) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A small superficial change to bin/now-deploy.js so that we can specify one or more aliases whilst deploying. **Examples** ``` now --alias a.com now --alias a.com --alias b.com ``` We handle the alias assignment serially so that the CLI output makes sense. **Some thoughts** - I’m hoping this PR can close out #172 - Aware this PR likely affects #68 - This is a superficial change, really we should update the lib/alias.js to handle multiple domains --- bin/now-deploy.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/now-deploy.js b/bin/now-deploy.js index 50a4431..7a57a16 100755 --- a/bin/now-deploy.js +++ b/bin/now-deploy.js @@ -11,6 +11,7 @@ import chalk from 'chalk' import minimist from 'minimist' import ms from 'ms' import publicSuffixList from 'psl' +import flatten from 'arr-flatten' // Ours import copy from '../lib/copy' @@ -167,7 +168,7 @@ const deploymentName = argv.name || false const apiUrl = argv.url || 'https://api.zeit.co' const isTTY = process.stdout.isTTY const quiet = !isTTY -const autoAlias = argv.alias || false +const autoAliases = argv.alias ? flatten([argv.alias]) : [] if (argv.config) { cfg.setConfigFile(argv.config) @@ -552,7 +553,7 @@ async function sync(token) { } } -const assignAlias = async (token, deployment) => { +const assignAlias = async (autoAlias, token, deployment) => { const type = publicSuffixList.isValid(autoAlias) ? 'alias' : 'uid' const aliases = new NowAlias(apiUrl, token, {debug}) @@ -586,8 +587,8 @@ function printLogs(host, token) { const logger = new Logger(host, {debug, quiet}) logger.on('close', async () => { - if (autoAlias) { - await assignAlias(token, host) + for (const autoAlias of autoAliases) { + await assignAlias(autoAlias, token, host) } if (!quiet) {