From dbf56429bf3da4ee7043e2e52bb7b68984cc2ff9 Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Sat, 28 May 2016 11:40:43 -0700 Subject: [PATCH] alias: match hostname prefix without `.now.sh` --- lib/alias.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/alias.js b/lib/alias.js index 5f510c7..82bfa56 100644 --- a/lib/alias.js +++ b/lib/alias.js @@ -1,6 +1,7 @@ import retry from 'async-retry'; import Now from '../lib'; import toHost from './to-host'; +import chalk from 'chalk'; export default class Alias extends Now { @@ -48,10 +49,14 @@ export default class Alias extends Now { key = 'uid'; } - const id = list.find((d) => d[key] === val); + const id = list.find((d) => { + return d[key] === val || // match entire host / uid + // match prefix + val + '.now.sh' === d.url; + }); if (!id) { - const err = new Error(`Deployment not found by ${key} "${deployment}"`); + const err = new Error(`Deployment not found by "${deployment}". Run ${chalk.dim('`now ls`')} to see your deployments.`); err.userError = true; throw err; }