Browse Source

Move duplicated code into utils module

master
tim neutkens 8 years ago
committed by Leo Lamprecht
parent
commit
de8470fe02
  1. 9
      bin/now-alias.js
  2. 9
      bin/now-certs.js
  3. 9
      bin/now-deploy.js
  4. 9
      bin/now-dns.js
  5. 9
      bin/now-domains.js
  6. 9
      bin/now-secrets.js
  7. 8
      lib/utils/exit.js

9
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)

9
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)

9
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

9
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)

9
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)

9
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)

8
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)
}
Loading…
Cancel
Save