~mna/hockeysim

501f9d0dfcf1cf5b33cf9a950c80e6457189cd09 — Martin Angers 1 year, 1 month ago 9c153d2
handle error messages a bit better
1 files changed, 10 insertions(+), 0 deletions(-)

M src/cli.js
M src/cli.js => src/cli.js +10 -0
@@ 1,8 1,18 @@
#!/usr/bin/env node
import process from 'process'
import yargs from 'yargs'
import chalk from 'chalk'

function errorMessage (msg, err, yargs) {
  if (err && err.message) {
    console.log (chalk.red.bold ('error: ') + err.message)
    process.exitCode = 1
  }
}

void yargs
  .scriptName ('hockeysim')
  .fail (errorMessage)
  .commandDir ('cmds')
  .demandCommand ()
  .strict ()