Skip to content

Commit

Permalink
rename "exclude" to "ignore" and create alias; closes #3871
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Apr 12, 2019
1 parent f1fe632 commit 198d590
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions example/config/.mocharc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ check-leaks: false
color: true
delay: false
diff: true
exclude:
- /path/to/some/excluded/file
ignore:
- /path/to/some/ignored/file
exit: false # could be expressed as "no-exit: true"
extension:
- js
Expand Down
6 changes: 3 additions & 3 deletions lib/cli/run-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ exports.handleRequires = (requires = []) => {
* @param {Object} [opts] - Options
* @param {string[]} [opts.extension] - File extensions to use
* @param {string[]} [opts.spec] - Files, dirs, globs to run
* @param {string[]} [opts.exclude] - Files, dirs, globs to exclude
* @param {string[]} [opts.ignore] - Files, dirs, globs to ignore
* @param {boolean} [opts.recursive=false] - Find files recursively
* @param {boolean} [opts.sort=false] - Sort test files
* @returns {string[]} List of files to test
* @private
*/
exports.handleFiles = ({
exclude = [],
ignore = [],
extension = [],
file = [],
recursive = false,
Expand All @@ -157,7 +157,7 @@ exports.handleFiles = ({
newFiles = [newFiles];
}
newFiles = newFiles.filter(fileName =>
exclude.every(pattern => !minimatch(fileName, pattern))
ignore.every(pattern => !minimatch(fileName, pattern))
);
}

Expand Down
3 changes: 2 additions & 1 deletion lib/cli/run-option-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
exports.types = {
array: [
'exclude',
'ignore',
'extension',
'file',
'global',
Expand Down Expand Up @@ -63,6 +63,7 @@ exports.aliases = {
global: ['globals'],
grep: ['g'],
growl: ['G'],
ignore: ['exclude'],
invert: ['i'],
'no-colors': ['C'],
reporter: ['R'],
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ exports.builder = yargs =>
description: 'Show diff on failure',
group: GROUPS.OUTPUT
},
exclude: {
ignore: {
defaultDescription: '(none)',
description: 'Ignore file(s) or glob pattern(s)',
group: GROUPS.FILES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var helpers = require('../helpers');
var runMochaJSON = helpers.runMochaJSON;
var resolvePath = helpers.resolveFixturePath;

describe('--exclude', function() {
describe('--ignore', function() {
/*
* Runs mocha in {path} with the given args.
* Calls handleResult with the result.
Expand All @@ -26,11 +26,11 @@ describe('--exclude', function() {
});
}

it('should exclude specific files', function(done) {
var fixtures = path.join('options', 'exclude', '*');
it('should ignore specific files', function(done) {
var fixtures = path.join('options', 'ignore', '*');
runMochaTest(
fixtures,
['--exclude', resolvePath(path.join('options', 'exclude', 'fail'))],
['--ignore', resolvePath(path.join('options', 'ignore', 'fail'))],
function(res) {
expect(res, 'to have passed')
.and('to have run test', 'should find this test')
Expand All @@ -40,11 +40,11 @@ describe('--exclude', function() {
);
});

it('should exclude globbed files', function(done) {
var fixtures = path.join('options', 'exclude', '**', '*');
it('should ignore globbed files', function(done) {
var fixtures = path.join('options', 'ignore', '**', '*');
runMochaTest(
fixtures,
['--exclude', '**/fail.fixture.js'],
['--ignore', '**/fail.fixture.js'],
function(res) {
expect(res, 'to have passed')
.and('not to have pending tests')
Expand All @@ -54,15 +54,15 @@ describe('--exclude', function() {
);
});

it('should exclude multiple patterns', function(done) {
var fixtures = path.join('options', 'exclude', '**', '*');
it('should ignore multiple patterns', function(done) {
var fixtures = path.join('options', 'ignore', '**', '*');
runMochaTest(
fixtures,
[
'--exclude',
resolvePath(path.join('options', 'exclude', 'fail')),
'--exclude',
resolvePath(path.join('options', 'exclude', 'nested', 'fail'))
'--ignore',
resolvePath(path.join('options', 'ignore', 'fail')),
'--ignore',
resolvePath(path.join('options', 'ignore', 'nested', 'fail'))
],
function(res) {
expect(res, 'to have passed')
Expand Down

0 comments on commit 198d590

Please sign in to comment.