CLI: Added better check for options

master
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 dot test/*.mjs')
console.log('eltro -r dot test/**/*.test.mjs')
console.log('')
process.exit(1)
}

View File

@ -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])
}

View File

@ -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)
})
})
/*****************************************