From 530a9fb3576b87e1d9c2818a679d495b995e3d1f Mon Sep 17 00:00:00 2001 From: Olli Vanhoja Date: Mon, 24 Oct 2016 20:26:29 +0300 Subject: [PATCH] Add a flag for skipping DNS verification (#94) Some registrars requires that the DNS records are already setup before delegating the domain to a nameserver. --- bin/now-domains.js | 6 ++++-- lib/domains.js | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/now-domains.js b/bin/now-domains.js index 011cd46..2cfc992 100755 --- a/bin/now-domains.js +++ b/bin/now-domains.js @@ -16,11 +16,12 @@ import NowDomains from '../lib/domains' const argv = minimist(process.argv.slice(2), { string: ['config', 'token'], - boolean: ['help', 'debug'], + boolean: ['help', 'debug', 'force'], alias: { help: 'h', config: 'c', debug: 'd', + force: 'f', token: 't' } }) @@ -36,6 +37,7 @@ const help = () => { -h, --help Output usage information -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline('FILE')} Config file -d, --debug Debug mode [off] + -f, --force Skip DNS verification -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline('TOKEN')} Login token ${chalk.dim('Examples:')} @@ -207,7 +209,7 @@ async function run(token) { const start = new Date() const name = String(args[0]) - const {uid, created} = await domain.add(name) + const {uid, created} = await domain.add(name, argv.force) const elapsed = ms(new Date() - start) if (created) { console.log(`${chalk.cyan('> Success!')} Domain ${chalk.bold(chalk.underline(name))} ${chalk.dim(`(${uid})`)} added [${elapsed}]`) diff --git a/lib/domains.js b/lib/domains.js index 1cc4b83..750e8ae 100644 --- a/lib/domains.js +++ b/lib/domains.js @@ -50,13 +50,17 @@ export default class Domains extends Now { }) } - async add(domain) { + async add(domain, skipVerification) { if (!domainRegex.test(domain)) { const err = new Error(`The supplied value ${chalk.bold(`"${domain}"`)} is not a valid domain.`) err.userError = true throw err } + if (skipVerification) { + return this.setupDomain(domain) + } + let ns try {