From b2a4c7e7f567c3edd687904ffe4e1e3295929b7d Mon Sep 17 00:00:00 2001 From: Leo Lamprecht Date: Wed, 28 Jun 2017 20:17:19 +0200 Subject: [PATCH] Prettified everything --- bin/now-alias.js | 39 +++++++++++++++++----------------- bin/now-billing.js | 10 ++++----- bin/now-deploy.js | 10 ++++----- bin/now-domains.js | 39 +++++++++++++++++----------------- lib/alias.js | 5 ++--- lib/get-files.js | 5 ++--- lib/utils/input/prompt-bool.js | 11 +++++----- 7 files changed, 58 insertions(+), 61 deletions(-) diff --git a/bin/now-alias.js b/bin/now-alias.js index 531ea75..e1f980e 100755 --- a/bin/now-alias.js +++ b/bin/now-alias.js @@ -189,25 +189,26 @@ async function run({ token, config: { currentTeam, user } }) { const header = [ ['', 'pathname', 'method', 'dest'].map(s => chalk.dim(s)) ] - const text = list.length === 0 - ? null - : table( - header.concat( - item.rules.map(rule => { - return [ - '', - rule.pathname ? rule.pathname : '', - rule.method ? rule.method : '*', - rule.dest - ] - }) - ), - { - align: ['l', 'l', 'l', 'l'], - hsep: ' '.repeat(2), - stringLength: strlen - } - ) + const text = + list.length === 0 + ? null + : table( + header.concat( + item.rules.map(rule => { + return [ + '', + rule.pathname ? rule.pathname : '', + rule.method ? rule.method : '*', + rule.dest + ] + }) + ), + { + align: ['l', 'l', 'l', 'l'], + hsep: ' '.repeat(2), + stringLength: strlen + } + ) console.log(text) } diff --git a/bin/now-billing.js b/bin/now-billing.js index 54e53cc..4d69535 100644 --- a/bin/now-billing.js +++ b/bin/now-billing.js @@ -123,9 +123,8 @@ if (argv.help || !subcommand) { // Builds a `choices` object that can be passesd to inquirer.prompt() function buildInquirerChoices(cards) { return cards.cards.map(card => { - const _default = card.id === cards.defaultCardId - ? ' ' + chalk.bold('(default)') - : '' + const _default = + card.id === cards.defaultCardId ? ' ' + chalk.bold('(default)') : '' const id = `${chalk.cyan(`ID: ${card.id}`)}${_default}` const number = `${chalk.gray('#### ').repeat(3)}${card.last4}` const str = [ @@ -159,9 +158,8 @@ async function run({ token, config: { currentTeam, user } }) { } const text = cards.cards .map(card => { - const _default = card.id === cards.defaultCardId - ? ' ' + chalk.bold('(default)') - : '' + const _default = + card.id === cards.defaultCardId ? ' ' + chalk.bold('(default)') : '' const id = `${chalk.gray('-')} ${chalk.cyan( `ID: ${card.id}` )}${_default}` diff --git a/bin/now-deploy.js b/bin/now-deploy.js index 04f1b21..90140e6 100755 --- a/bin/now-deploy.js +++ b/bin/now-deploy.js @@ -200,9 +200,8 @@ const wantsPublic = argv.public const apiUrl = argv.url || 'https://api.zeit.co' const isTTY = process.stdout.isTTY const quiet = !isTTY -const autoAliases = typeof argv.alias === 'undefined' - ? false - : flatten([argv.alias]) +const autoAliases = + typeof argv.alias === 'undefined' ? false : flatten([argv.alias]) if (argv.config) { cfg.setConfigFile(argv.config) @@ -449,9 +448,8 @@ async function sync({ token, config: { currentTeam, user } }) { } if (dotenvOption) { - const dotenvFileName = typeof dotenvOption === 'string' - ? dotenvOption - : '.env' + const dotenvFileName = + typeof dotenvOption === 'string' ? dotenvOption : '.env' if (!fs.existsSync(dotenvFileName)) { error(`--dotenv flag is set but ${dotenvFileName} file is missing`) diff --git a/bin/now-domains.js b/bin/now-domains.js index f76c0a9..ccf38dc 100755 --- a/bin/now-domains.js +++ b/bin/now-domains.js @@ -197,25 +197,26 @@ async function run({ token, config: { currentTeam, user } }) { const header = [ ['', 'domain', 'dns', 'verified', 'created'].map(s => chalk.dim(s)) ] - const out = domains.length === 0 - ? null - : table( - header.concat( - domains.map(domain => { - const ns = domain.isExternal ? 'external' : 'zeit.world' - const url = chalk.bold(domain.name) - const time = chalk.gray( - ms(current - new Date(domain.created)) + ' ago' - ) - return ['', url, ns, domain.verified, time] - }) - ), - { - align: ['l', 'l', 'l', 'l', 'l'], - hsep: ' '.repeat(2), - stringLength: strlen - } - ) + const out = + domains.length === 0 + ? null + : table( + header.concat( + domains.map(domain => { + const ns = domain.isExternal ? 'external' : 'zeit.world' + const url = chalk.bold(domain.name) + const time = chalk.gray( + ms(current - new Date(domain.created)) + ' ago' + ) + return ['', url, ns, domain.verified, time] + }) + ), + { + align: ['l', 'l', 'l', 'l', 'l'], + hsep: ' '.repeat(2), + stringLength: strlen + } + ) const elapsed_ = ms(new Date() - start_) console.log( diff --git a/lib/alias.js b/lib/alias.js index 6a8343e..0ee8083 100644 --- a/lib/alias.js +++ b/lib/alias.js @@ -671,9 +671,8 @@ module.exports = class Alias extends Now { const _domain = publicSuffixList.parse(alias).domain const _domainInfo = await this.getDomain(_domain) - const domainInfo = _domainInfo && !_domainInfo.error - ? _domainInfo - : undefined + const domainInfo = + _domainInfo && !_domainInfo.error ? _domainInfo : undefined const { domain, nameservers } = domainInfo ? { domain: _domain } : await this.getNameservers(alias) diff --git a/lib/get-files.js b/lib/get-files.js index 1622f75..0147889 100644 --- a/lib/get-files.js +++ b/lib/get-files.js @@ -176,9 +176,8 @@ async function npm( // Compile list of ignored patterns and files const npmIgnore = await maybeRead(resolve(path, '.npmignore'), null) - const gitIgnore = npmIgnore === null - ? await maybeRead(resolve(path, '.gitignore')) - : null + const gitIgnore = + npmIgnore === null ? await maybeRead(resolve(path, '.gitignore')) : null const filter = ignore() .add( diff --git a/lib/utils/input/prompt-bool.js b/lib/utils/input/prompt-bool.js index 56cda9a..576b44f 100644 --- a/lib/utils/input/prompt-bool.js +++ b/lib/utils/input/prompt-bool.js @@ -46,11 +46,12 @@ module.exports = ( } } - const defaultText = defaultValue === null - ? `[${yesChar}|${noChar}]` - : defaultValue - ? `[${chalk.bold(yesChar.toUpperCase())}|${noChar}]` - : `[${yesChar}|${chalk.bold(noChar.toUpperCase())}]` + const defaultText = + defaultValue === null + ? `[${yesChar}|${noChar}]` + : defaultValue + ? `[${chalk.bold(yesChar.toUpperCase())}|${noChar}]` + : `[${yesChar}|${chalk.bold(noChar.toUpperCase())}]` stdout.write(`${chalk.gray('>')} ${label} ${chalk.gray(defaultText)} `) stdin.on('data', onData) })