diff --git a/cli.mjs b/cli.mjs index 53aff84..f7dd5ac 100644 --- a/cli.mjs +++ b/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) } diff --git a/lib/cli.mjs b/lib/cli.mjs index 97051b7..2455c2c 100644 --- a/lib/cli.mjs +++ b/lib/cli.mjs @@ -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]) } diff --git a/test/cli.test.mjs b/test/cli.test.mjs index 0df2ec9..582740e 100644 --- a/test/cli.test.mjs +++ b/test/cli.test.mjs @@ -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) + }) }) /*****************************************