From 32ad62d57c0810b5069a6555e0359257c7602954 Mon Sep 17 00:00:00 2001 From: Tony Kovanen Date: Mon, 30 May 2016 11:03:42 +0300 Subject: [PATCH] `now alias ls`: accept deployment url --- lib/alias.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/alias.js b/lib/alias.js index 5c4976a..38d1fb6 100644 --- a/lib/alias.js +++ b/lib/alias.js @@ -6,9 +6,10 @@ import chalk from 'chalk'; export default class Alias extends Now { - async ls (target) { - if (target) { - const res = await this._fetch(`/now/deployments/${target}/aliases`); + async ls (deployment) { + if (deployment) { + const target = await this.findDeployment(deployment); + const res = await this._fetch(`/now/deployments/${target.uid}/aliases`); const body = await res.json(); return body.aliases; } @@ -33,10 +34,9 @@ export default class Alias extends Now { console.log(`${chalk.cyan('> Success!')}`); } - async set (deployment, alias) { + async findDeployment (deployment) { const list = await this.list(); let key, val; - if (/\./.test(deployment)) { val = toHost(deployment); key = 'url'; @@ -60,6 +60,11 @@ export default class Alias extends Now { return false; }); + return depl; + } + + async set (deployment, alias) { + const depl = await this.findDeployment(deployment); if (!depl) { const err = new Error(`Deployment not found by "${deployment}". Run ${chalk.dim('`now ls`')} to see your deployments.`); err.userError = true;