Browse Source

`now alias ls`: accept deployment url

master
Tony Kovanen 9 years ago
parent
commit
32ad62d57c
  1. 15
      lib/alias.js

15
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;

Loading…
Cancel
Save