Skip to content

Commit

Permalink
Fix couple errors missing codes
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jan 8, 2019
1 parent 9d62030 commit 4e7f923
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/cli/run.js
Expand Up @@ -11,6 +11,7 @@ const Mocha = require('../mocha');
const ansi = require('ansi-colors');
const errors = require('../errors');
const createInvalidArgumentValueError = errors.createInvalidArgumentValueError;

This comment has been minimized.

Copy link
@boneskull

boneskull Jan 11, 2019

Member

you may want to deref these:

const {createX, createY} = require(../errors’);
const createMissingArgumentError = errors.createMissingArgumentError;

const {
list,
Expand Down Expand Up @@ -258,15 +259,19 @@ exports.builder = yargs =>

// yargs.implies() isn't flexible enough to handle this
if (argv.invert && !('fgrep' in argv || 'grep' in argv)) {
throw new Error(
'"--invert" requires one of "--fgrep <str>" or "--grep <regexp>"'
throw createMissingArgumentError(
'"--invert" requires one of "--fgrep <str>" or "--grep <regexp>"',
'--invert',
argv.invert
);
}

if (argv.compilers) {
throw new Error(
throw createInvalidArgumentValueError(
`--compilers is DEPRECATED and no longer supported.
See ${ansi.cyan('https://git.io/vdcSr')} for migration information.`
See ${ansi.cyan('https://git.io/vdcSr')} for migration information.`,
'--compilers',
argv.compilers
);
}

Expand Down
20 changes: 20 additions & 0 deletions test/integration/options.spec.js
Expand Up @@ -346,6 +346,26 @@ describe('options', function() {
done();
});
});

it('fails if no --grep', function(done) {
args = ['--invert'];
runMocha(
'options/grep.fixture.js',
args,
function(err, res) {
if (err) {
done(err);
return;
}
expect(res, 'to satisfy', {
code: 1,
output: /fgrep/
});
done();
},
{stdio: 'pipe'}
);
});
});
});

Expand Down

0 comments on commit 4e7f923

Please sign in to comment.