diff --git a/bin/now-alias.js b/bin/now-alias.js index bb4221f..c371874 100755 --- a/bin/now-alias.js +++ b/bin/now-alias.js @@ -14,6 +14,7 @@ const cfg = require('../lib/cfg') const {error} = require('../lib/error') const toHost = require('../lib/to-host') const {reAlias} = require('../lib/re-alias') +const exit = require('../lib/utils/exit') const argv = minimist(process.argv.slice(2), { string: ['config', 'token'], @@ -83,14 +84,6 @@ if (argv.config) { cfg.setConfigFile(argv.config) } -const exit = code => { - // we give stdout some time to flush out - // because there's a node bug where - // stdout writes are asynchronous - // https://github.com/nodejs/node/issues/6456 - setTimeout(() => process.exit(code || 0), 100) -} - if (argv.help) { help() exit(0) diff --git a/bin/now-certs.js b/bin/now-certs.js index e86d830..31f5848 100755 --- a/bin/now-certs.js +++ b/bin/now-certs.js @@ -16,6 +16,7 @@ const cfg = require('../lib/cfg') const {handleError, error} = require('../lib/error') const NowCerts = require('../lib/certs') const login = require('../lib/login') +const exit = require('../lib/utils/exit') const argv = minimist(process.argv.slice(2), { string: ['config', 'token', 'crt', 'key', 'ca'], @@ -77,14 +78,6 @@ if (argv.config) { cfg.setConfigFile(argv.config) } -const exit = code => { - // we give stdout some time to flush out - // because there's a node bug where - // stdout writes are asynchronous - // https://github.com/nodejs/node/issues/6456 - setTimeout(() => process.exit(code || 0), 100) -} - if (argv.help || !subcommand) { help() exit(0) diff --git a/bin/now-deploy.js b/bin/now-deploy.js index c765be2..d4e054b 100755 --- a/bin/now-deploy.js +++ b/bin/now-deploy.js @@ -12,6 +12,7 @@ const minimist = require('minimist') const ms = require('ms') const flatten = require('arr-flatten') const dotenv = require('dotenv') +const exit = require('../lib/utils/exit') // Ours const copy = require('../lib/copy') @@ -148,14 +149,6 @@ if (path) { // If the current deployment is a repo const gitRepo = {} -const exit = code => { - // we give stdout some time to flush out - // because there's a node bug where - // stdout writes are asynchronous - // https://github.com/nodejs/node/issues/6456 - setTimeout(() => process.exit(code || 0), 100) -} - // options let forceNew = argv.force const debug = argv.debug diff --git a/bin/now-dns.js b/bin/now-dns.js index 179642d..65be002 100755 --- a/bin/now-dns.js +++ b/bin/now-dns.js @@ -13,6 +13,7 @@ const indent = require('../lib/indent') const login = require('../lib/login') const strlen = require('../lib/strlen') const {handleError, error} = require('../lib/error') +const exit = require('../lib/utils/exit') const argv = minimist(process.argv.slice(2), { string: ['config'], @@ -66,14 +67,6 @@ if (argv.config) { cfg.setConfigFile(argv.config) } -const exit = code => { - // we give stdout some time to flush out - // because there's a node bug where - // stdout writes are asynchronous - // https://github.com/nodejs/node/issues/6456 - setTimeout(() => process.exit(code || 0), 100) -} - if (argv.help || !subcommand) { help() exit(0) diff --git a/bin/now-domains.js b/bin/now-domains.js index b71b676..362aef3 100755 --- a/bin/now-domains.js +++ b/bin/now-domains.js @@ -13,6 +13,7 @@ const {error} = require('../lib/error') const toHost = require('../lib/to-host') const strlen = require('../lib/strlen') const NowDomains = require('../lib/domains') +const exit = require('../lib/utils/exit') const argv = minimist(process.argv.slice(2), { string: ['config', 'token'], @@ -103,14 +104,6 @@ if (argv.config) { cfg.setConfigFile(argv.config) } -const exit = code => { - // we give stdout some time to flush out - // because there's a node bug where - // stdout writes are asynchronous - // https://github.com/nodejs/node/issues/6456 - setTimeout(() => process.exit(code || 0), 100) -} - if (argv.help || !subcommand) { help() exit(0) diff --git a/bin/now-secrets.js b/bin/now-secrets.js index 4570c7f..dbda319 100755 --- a/bin/now-secrets.js +++ b/bin/now-secrets.js @@ -12,6 +12,7 @@ const cfg = require('../lib/cfg') const {handleError, error} = require('../lib/error') const NowSecrets = require('../lib/secrets') const login = require('../lib/login') +const exit = require('../lib/utils/exit') const argv = minimist(process.argv.slice(2), { string: ['config', 'token'], @@ -78,14 +79,6 @@ if (argv.config) { cfg.setConfigFile(argv.config) } -const exit = code => { - // we give stdout some time to flush out - // because there's a node bug where - // stdout writes are asynchronous - // https://github.com/nodejs/node/issues/6456 - setTimeout(() => process.exit(code || 0), 100) -} - if (argv.help || !subcommand) { help() exit(0) diff --git a/lib/utils/exit.js b/lib/utils/exit.js new file mode 100644 index 0000000..c2fb1a8 --- /dev/null +++ b/lib/utils/exit.js @@ -0,0 +1,8 @@ +module.exports = code => { + // we give stdout some time to flush out + // because there's a node bug where + // stdout writes are asynchronous + // https://github.com/nodejs/node/issues/6456 + /* eslint-disable unicorn/no-process-exit */ + setTimeout(() => process.exit(code || 0), 100) +}