Skip to content

Commit

Permalink
fix(server): replace optimist on yargs lib
Browse files Browse the repository at this point in the history
fix #2473
  • Loading branch information
anthony-redFox committed Mar 29, 2020
1 parent ffad7fa commit a3457e0
Show file tree
Hide file tree
Showing 4 changed files with 330 additions and 59 deletions.
20 changes: 10 additions & 10 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const path = require('path')
const assert = require('assert')
const optimist = require('optimist')
const yargs = require('yargs')
const fs = require('graceful-fs')

const Server = require('./server')
Expand All @@ -11,7 +11,7 @@ const constant = require('./constants')

function processArgs (argv, options, fs, path) {
if (argv.help) {
console.log(optimist.help())
console.log(yargs.help())
process.exit(0)
}

Expand Down Expand Up @@ -152,7 +152,7 @@ function argsBeforeDoubleDash (argv) {
}

function describeShared () {
optimist
yargs
.usage('Karma - Spectacular Test Runner for JavaScript.\n\n' +
'Usage:\n' +
' $0 <command>\n\n' +
Expand All @@ -167,7 +167,7 @@ function describeShared () {
}

function describeInit () {
optimist
yargs
.usage('Karma - Spectacular Test Runner for JavaScript.\n\n' +
'INIT - Initialize a config file.\n\n' +
'Usage:\n' +
Expand All @@ -179,7 +179,7 @@ function describeInit () {
}

function describeStart () {
optimist
yargs
.usage('Karma - Spectacular Test Runner for JavaScript.\n\n' +
'START - Start the server / do a single run.\n\n' +
'Usage:\n' +
Expand All @@ -205,7 +205,7 @@ function describeStart () {
}

function describeRun () {
optimist
yargs
.usage('Karma - Spectacular Test Runner for JavaScript.\n\n' +
'RUN - Run the tests (requires running server).\n\n' +
'Usage:\n' +
Expand All @@ -221,7 +221,7 @@ function describeRun () {
}

function describeStop () {
optimist
yargs
.usage('Karma - Spectacular Test Runner for JavaScript.\n\n' +
'STOP - Stop the server (requires running server).\n\n' +
'Usage:\n' +
Expand All @@ -232,7 +232,7 @@ function describeStop () {
}

function describeCompletion () {
optimist
yargs
.usage('Karma - Spectacular Test Runner for JavaScript.\n\n' +
'COMPLETION - Bash/ZSH completion for karma.\n\n' +
'Installation:\n' +
Expand All @@ -245,7 +245,7 @@ function printRunnerProgress (data) {
}

exports.process = function () {
const argv = optimist.parse(argsBeforeDoubleDash(process.argv.slice(2)))
const argv = yargs.parse(argsBeforeDoubleDash(process.argv.slice(2)))
const options = {
cmd: argv._.shift()
}
Expand Down Expand Up @@ -280,7 +280,7 @@ exports.process = function () {
} else {
console.error('Unknown command "' + options.cmd + '".')
}
optimist.showHelp()
yargs.showHelp()
process.exit(1)
}

Expand Down
Loading

0 comments on commit a3457e0

Please sign in to comment.