diff --git a/bin/now-domains b/bin/now-domains index 1de7c6a..83f6813 100755 --- a/bin/now-domains +++ b/bin/now-domains @@ -7,6 +7,7 @@ import login from '../lib/login'; import * as cfg from '../lib/cfg'; import { error } from '../lib/error'; import toHost from '../lib/to-host'; +import strlen from '../lib/strlen'; import NowDomains from '../lib/domains'; const argv = minimist(process.argv.slice(2), { @@ -127,15 +128,19 @@ async function run (token) { const domains = await domain.ls(); domains.sort((a, b) => new Date(b.created) - new Date(a.created)); const current = new Date(); - const out = table(domains.map((domain) => { + const header = [['', 'id', 'dns', 'url', 'created']]; + const out = table(header.concat(domains.map((domain) => { + const ns = domain.isExternal ? 'external' : 'zeit.world'; const url = chalk.underline(`https://${domain.name}`); const time = chalk.gray(ms(current - new Date(domain.created)) + ' ago'); return [ + '', domain.uid, + ns, url, time ]; - }), { align: ['r', 'l', 'l'], hsep: ' '.repeat(2) }); + })), { align: ['l', 'r', 'l', 'l', 'l'], hsep: ' '.repeat(2), stringLength: strlen }); const elapsed_ = ms(new Date() - start_); console.log(`> ${domains.length} domain${domains.length > 1 ? 's' : ''} found ${chalk.gray(`[${elapsed_}]`)}`); diff --git a/lib/strlen.js b/lib/strlen.js new file mode 100644 index 0000000..35c3cf2 --- /dev/null +++ b/lib/strlen.js @@ -0,0 +1,3 @@ +export default function strlen (str) { + return str.replace(/\x1b[^m]*m/g, '').length; +}