CLI: Added better check for options
This commit is contained in:
parent
b8deafd11c
commit
4fa7f0314b
3 changed files with 14 additions and 0 deletions
1
cli.mjs
1
cli.mjs
|
@ -27,6 +27,7 @@ function PrintHelp() {
|
|||
console.log('eltro test/mytest.mjs')
|
||||
console.log('eltro dot test/*.mjs')
|
||||
console.log('eltro -r dot test/**/*.test.mjs')
|
||||
console.log('')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,9 @@ CLI.prototype.parseOptions = function(args) {
|
|||
}
|
||||
this.reporter = args[i + 1]
|
||||
i++
|
||||
} else if (args[i][0] === '-') {
|
||||
this.errored = true
|
||||
return
|
||||
} else {
|
||||
this.targets.push(args[i])
|
||||
}
|
||||
|
|
|
@ -72,6 +72,16 @@ e.describe('CLI', function() {
|
|||
assert.deepEqual(cli.targets, ['test/**'])
|
||||
assert.notOk(cli.errored)
|
||||
})
|
||||
|
||||
e.test('should mark errored if invalid shorthand option', function() {
|
||||
cli.parseOptions(['-A'])
|
||||
assert.ok(cli.errored)
|
||||
})
|
||||
|
||||
e.test('should mark errored if invalid longhand option', function() {
|
||||
cli.parseOptions(['--asdf'])
|
||||
assert.ok(cli.errored)
|
||||
})
|
||||
})
|
||||
|
||||
/*****************************************
|
||||
|
|
Loading…
Reference in a new issue