CLI: Added better check for options

This commit is contained in:
Jonatan Nilsson 2020-04-01 15:46:11 +00:00
parent b8deafd11c
commit 4fa7f0314b
3 changed files with 14 additions and 0 deletions

View file

@ -27,6 +27,7 @@ function PrintHelp() {
console.log('eltro test/mytest.mjs') console.log('eltro test/mytest.mjs')
console.log('eltro dot test/*.mjs') console.log('eltro dot test/*.mjs')
console.log('eltro -r dot test/**/*.test.mjs') console.log('eltro -r dot test/**/*.test.mjs')
console.log('')
process.exit(1) process.exit(1)
} }

View file

@ -28,6 +28,9 @@ CLI.prototype.parseOptions = function(args) {
} }
this.reporter = args[i + 1] this.reporter = args[i + 1]
i++ i++
} else if (args[i][0] === '-') {
this.errored = true
return
} else { } else {
this.targets.push(args[i]) this.targets.push(args[i])
} }

View file

@ -72,6 +72,16 @@ e.describe('CLI', function() {
assert.deepEqual(cli.targets, ['test/**']) assert.deepEqual(cli.targets, ['test/**'])
assert.notOk(cli.errored) 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)
})
}) })
/***************************************** /*****************************************