karma
Advanced tools
Comparing version 5.0.4 to 5.0.5
115
lib/cli.js
@@ -13,12 +13,2 @@ 'use strict' | ||
function processArgs (argv, options, fs, path) { | ||
if (argv.help) { | ||
console.log(yargs.help()) | ||
process.exit(0) | ||
} | ||
if (argv.version) { | ||
console.log(`Karma version: ${constant.VERSION}`) | ||
process.exit(0) | ||
} | ||
// TODO(vojta): warn/throw when unknown argument (probably mispelled) | ||
@@ -134,2 +124,6 @@ Object.getOwnPropertyNames(argv).forEach(function (name) { | ||
if (options.cmd === 'run') { | ||
options.clientArgs = parseClientArgs(process.argv) | ||
} | ||
return options | ||
@@ -156,13 +150,15 @@ } | ||
function describeShared () { | ||
yargs | ||
function describeRoot () { | ||
return yargs | ||
.usage('Karma - Spectacular Test Runner for JavaScript.\n\n' + | ||
'Run --help with particular command to see its description and available options.\n\n' + | ||
'Usage:\n' + | ||
' $0 <command>\n\n' + | ||
'Commands:\n' + | ||
' start [<configFile>] [<options>] Start the server / do single run.\n' + | ||
' init [<configFile>] Initialize a config file.\n' + | ||
' run [<options>] [ -- <clientArgs>] Trigger a test run.\n' + | ||
' completion Shell completion for karma.\n\n' + | ||
'Run --help with particular command to see its description and available options.') | ||
' $0 <command>') | ||
.command('init', 'Initialize a config file.', describeInit) | ||
.command('start', 'Start the server / do a single run.', describeStart) | ||
.command('run', 'Trigger a test run.', describeRun) | ||
.command('stop', 'Stop the server.', describeStop) | ||
.command('completion', 'Shell completion for karma.', describeCompletion) | ||
.demandCommand(1, 'Command not specified.') | ||
.strictCommands() | ||
.describe('help', 'Print usage and options.') | ||
@@ -172,3 +168,3 @@ .describe('version', 'Print current version.') | ||
function describeInit () { | ||
function describeInit (yargs) { | ||
yargs | ||
@@ -178,10 +174,11 @@ .usage('Karma - Spectacular Test Runner for JavaScript.\n\n' + | ||
'Usage:\n' + | ||
' $0 init [<configFile>]') | ||
' $0 init [configFile]') | ||
.strictCommands(false) | ||
.version(false) | ||
.describe('log-level', '<disable | error | warn | info | debug> Level of logging.') | ||
.describe('colors', 'Use colors when reporting and printing logs.') | ||
.describe('no-colors', 'Do not use colors when reporting or printing logs.') | ||
.describe('help', 'Print usage and options.') | ||
} | ||
function describeStart () { | ||
function describeStart (yargs) { | ||
yargs | ||
@@ -191,3 +188,5 @@ .usage('Karma - Spectacular Test Runner for JavaScript.\n\n' + | ||
'Usage:\n' + | ||
' $0 start [<configFile>] [<options>]') | ||
' $0 start [configFile]') | ||
.strictCommands(false) | ||
.version(false) | ||
.describe('port', '<integer> Port where the server is running.') | ||
@@ -210,6 +209,5 @@ .describe('auto-watch', 'Auto watch source files and run on change.') | ||
.describe('no-fail-on-failing-test-suite', 'Do not fail on failing test suite.') | ||
.describe('help', 'Print usage and options.') | ||
} | ||
function describeRun () { | ||
function describeRun (yargs) { | ||
yargs | ||
@@ -219,3 +217,5 @@ .usage('Karma - Spectacular Test Runner for JavaScript.\n\n' + | ||
'Usage:\n' + | ||
' $0 run [<configFile>] [<options>] [ -- <clientArgs>]') | ||
' $0 run [configFile] [-- <clientArgs>]') | ||
.strictCommands(false) | ||
.version(false) | ||
.describe('port', '<integer> Port where the server is listening.') | ||
@@ -225,3 +225,2 @@ .describe('no-refresh', 'Do not re-glob all the patterns.') | ||
.describe('no-fail-on-empty-test-suite', 'Do not fail on empty test suite.') | ||
.describe('help', 'Print usage.') | ||
.describe('log-level', '<disable | error | warn | info | debug> Level of logging.') | ||
@@ -232,3 +231,3 @@ .describe('colors', 'Use colors when reporting and printing logs.') | ||
function describeStop () { | ||
function describeStop (yargs) { | ||
yargs | ||
@@ -238,9 +237,10 @@ .usage('Karma - Spectacular Test Runner for JavaScript.\n\n' + | ||
'Usage:\n' + | ||
' $0 run [<configFile>] [<options>]') | ||
' $0 stop [configFile]') | ||
.strictCommands(false) | ||
.version(false) | ||
.describe('port', '<integer> Port where the server is listening.') | ||
.describe('log-level', '<disable | error | warn | info | debug> Level of logging.') | ||
.describe('help', 'Print usage.') | ||
} | ||
function describeCompletion () { | ||
function describeCompletion (yargs) { | ||
yargs | ||
@@ -250,4 +250,5 @@ .usage('Karma - Spectacular Test Runner for JavaScript.\n\n' + | ||
'Installation:\n' + | ||
' $0 completion >> ~/.bashrc\n') | ||
.describe('help', 'Print usage.') | ||
' $0 completion >> ~/.bashrc') | ||
.strictCommands(false) | ||
.version(false) | ||
} | ||
@@ -259,46 +260,8 @@ | ||
exports.process = function () { | ||
const argv = yargs.parse(argsBeforeDoubleDash(process.argv.slice(2))) | ||
const options = { | ||
cmd: argv._.shift() | ||
} | ||
switch (options.cmd) { | ||
case 'start': | ||
describeStart() | ||
break | ||
case 'run': | ||
describeRun() | ||
options.clientArgs = parseClientArgs(process.argv) | ||
break | ||
case 'stop': | ||
describeStop() | ||
break | ||
case 'init': | ||
describeInit() | ||
break | ||
case 'completion': | ||
describeCompletion() | ||
break | ||
default: | ||
describeShared() | ||
if (!options.cmd) { | ||
processArgs(argv, options, fs, path) | ||
console.error('Command not specified.') | ||
} else { | ||
console.error('Unknown command "' + options.cmd + '".') | ||
} | ||
yargs.showHelp() | ||
process.exit(1) | ||
} | ||
return processArgs(argv, options, fs, path) | ||
exports.process = () => { | ||
const argv = describeRoot().parse(argsBeforeDoubleDash(process.argv.slice(2))) | ||
return processArgs(argv, { cmd: argv._.shift() }, fs, path) | ||
} | ||
exports.run = function () { | ||
exports.run = () => { | ||
const config = exports.process() | ||
@@ -305,0 +268,0 @@ |
@@ -480,3 +480,3 @@ { | ||
}, | ||
"version": "5.0.4", | ||
"version": "5.0.5", | ||
"license": "MIT", | ||
@@ -483,0 +483,0 @@ "husky": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
496070
10331