All files / bin index.js

82.35% Statements 28/34
66.67% Branches 8/12
62.5% Functions 5/8
84.38% Lines 27/32

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51    9x 9x 9x 9x 9x 9x 9x 9x       9x 9x 8x     9x 5x 5x     9x         9x 9x 9x 5x 5x   9x         9x 9x   9x 9x   9x       9x  
#!/usr/bin/env node
 
const process = require('process')
const isHelp = process.argv.includes('-h') || process.argv.includes('--help')
const Ora = require('ora')
const Chalk = require('chalk')
const target = process.env.NODE_ENV === 'production' ? 'dist' : 'libs'
const Cli = require(`../${target}`)
const title = '[SCAFFOLDING CLI]'
const spinner = Ora({
  color: 'green',
  text: title
})
const startSpinner = () => {
  if (!isHelp) {
    setImmediate(spinner.start.bind(spinner))
  }
}
const stopSpinner = () => {
  Eif (!isHelp) {
    setTimeout(spinner.stop.bind(spinner), 1000)
  }
}
const changeSpinnerStyle = color => {
  if (!isHelp) {
    spinner.color = color
  }
}
const log = msg => console.log(Chalk.cyan.bgBlack.bold(msg))
const logError = e => console.log(Chalk.red.bgBlack.bold(e))
const resolve = res => {
  stopSpinner()
  log('CREATING SCAFFOLDING FILE[S] SUCCESSFULLY!')
}
const reject = e => {
  changeSpinnerStyle('red')
  stopSpinner()
  logError(`FAILED TO CREATE SCAFFOLDING FILE[S]! DETAIL: ${e.message}`)
}
const main = async () => {
  if (!isHelp) {
  }
  console.log(Chalk.cyan.bgBlack.bold(title))
  startSpinner()
 
  return await Cli.run()
    .then(resolve)
    .catch(reject)
}
main()