From c545968ff6d37659f6c0b937f0bf0a504b9adf21 Mon Sep 17 00:00:00 2001 From: Leo Lamprecht Date: Fri, 10 Feb 2017 22:59:26 +0100 Subject: [PATCH] Don't throw an error if alias doesn't exist --- lib/re-alias.js | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/lib/re-alias.js b/lib/re-alias.js index 7860279..d7cbb0a 100644 --- a/lib/re-alias.js +++ b/lib/re-alias.js @@ -3,7 +3,6 @@ const {join} = require('path') // Packages const fs = require('fs-promise') -const publicSuffixList = require('psl') const chalk = require('chalk') // Ours @@ -12,38 +11,11 @@ const readMetaData = require('./read-metadata') const NowAlias = require('./alias') exports.assignAlias = async (autoAlias, token, deployment, apiUrl, debug) => { - const type = publicSuffixList.isValid(autoAlias) ? 'alias' : 'uid' - const aliases = new NowAlias(apiUrl, token, {debug}) - const list = await aliases.ls() - - let related - - // Check if alias even exists - for (const alias of list) { - if (alias[type] === autoAlias) { - related = alias - break - } - } - - // If alias doesn't exist - if (!related) { - // Check if the uid was actually an alias - if (type === 'uid') { - return exports.assignAlias(`${autoAlias}.now.sh`, token, deployment) - } - - // If not, throw an error - const withID = type === 'uid' ? 'with ID ' : '' - error(`Alias ${withID}"${autoAlias}" doesn't exist`) - return - } - - console.log(`> Assigning alias ${chalk.bold.underline(related.alias)} to deployment...`) + console.log(`> Assigning alias ${chalk.bold.underline(autoAlias)} to deployment...`) // Assign alias - await aliases.set(String(deployment), String(related.alias)) + await aliases.set(String(deployment), String(autoAlias)) } exports.reAlias = async (token, host, help, exit) => {