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;