Skip to content

Commit 2439e4d

Browse files
committed
rename "exclude" to "ignore" and create alias; closes #3871
1 parent f1fe632 commit 2439e4d

File tree

10 files changed

+27
-26
lines changed

10 files changed

+27
-26
lines changed

docs/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ Mocha supports the `err.expected` and `err.actual` properties of any thrown `Ass
817817

818818
<!-- AUTO-GENERATED-CONTENT:START (usage:executable=bin/mocha) -->
819819

820-
```plain
820+
```text
821821
822822
mocha [spec..]
823823
@@ -864,7 +864,7 @@ Configuration
864864
--package Path to package.json for config [string]
865865
866866
File Handling
867-
--exclude Ignore file(s) or glob pattern(s)
867+
--ignore, --exclude Ignore file(s) or glob pattern(s)
868868
[array] [default: (none)]
869869
--extension, --watch-extensions File extension(s) to load and/or watch
870870
[array] [default: js]
@@ -883,7 +883,7 @@ Test Filters
883883
884884
Positional Arguments
885885
spec One or more files, directories, or globs to test
886-
[array] [default: ["test/"]]
886+
[array] [default: ["test"]]
887887
888888
Other Options
889889
--help, -h Show usage information & exit [boolean]
@@ -1075,9 +1075,9 @@ Specify an explicit path to a [`package.json` file](#configuring-mocha-node-js)
10751075

10761076
By default, Mocha looks for a `package.json` in the current working directory or nearest ancestor, and will use the first file found (regardless of whether it contains a `mocha` property); to suppress `package.json` lookup, use `--no-package`.
10771077

1078-
### `--exclude <file/directory/glob>`
1078+
### `--ignore <file|directory|glob>`
10791079

1080-
Explicitly exclude one or more files, directories or "globs" that would otherwise be loaded.
1080+
Explicitly ignore (exclude) one or more test files, directories or globs (e.g., `some/**/files*`) that would otherwise be loaded.
10811081

10821082
Files specified using `--file` _are not affected_ by this option.
10831083

@@ -1093,7 +1093,7 @@ Affects `--watch` behavior.
10931093

10941094
Specifying `--extension` will _remove_ `.js` as a test file extension; use `--extension js` to re-add it. For example, to load `.mjs` and `.js` test files, you must supply `--extension mjs --extension js`.
10951095

1096-
### `--file <file/directory/glob>`
1096+
### `--file <file|directory|glob>`
10971097

10981098
Explicitly _include_ a test file to be loaded before other test files files. Multiple uses of `--file` are allowed, and will be loaded in order given.
10991099

example/config/.mocharc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ check-leaks: false
66
color: true
77
delay: false
88
diff: true
9-
exclude:
10-
- /path/to/some/excluded/file
9+
ignore:
10+
- /path/to/some/ignored/file
1111
exit: false # could be expressed as "no-exit: true"
1212
extension:
1313
- js

lib/cli/run-helpers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ exports.handleRequires = (requires = []) => {
123123
* @param {Object} [opts] - Options
124124
* @param {string[]} [opts.extension] - File extensions to use
125125
* @param {string[]} [opts.spec] - Files, dirs, globs to run
126-
* @param {string[]} [opts.exclude] - Files, dirs, globs to exclude
126+
* @param {string[]} [opts.ignore] - Files, dirs, globs to ignore
127127
* @param {boolean} [opts.recursive=false] - Find files recursively
128128
* @param {boolean} [opts.sort=false] - Sort test files
129129
* @returns {string[]} List of files to test
130130
* @private
131131
*/
132132
exports.handleFiles = ({
133-
exclude = [],
133+
ignore = [],
134134
extension = [],
135135
file = [],
136136
recursive = false,
@@ -157,7 +157,7 @@ exports.handleFiles = ({
157157
newFiles = [newFiles];
158158
}
159159
newFiles = newFiles.filter(fileName =>
160-
exclude.every(pattern => !minimatch(fileName, pattern))
160+
ignore.every(pattern => !minimatch(fileName, pattern))
161161
);
162162
}
163163

lib/cli/run-option-metadata.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
exports.types = {
1616
array: [
17-
'exclude',
17+
'ignore',
1818
'extension',
1919
'file',
2020
'global',
@@ -63,6 +63,7 @@ exports.aliases = {
6363
global: ['globals'],
6464
grep: ['g'],
6565
growl: ['G'],
66+
ignore: ['exclude'],
6667
invert: ['i'],
6768
'no-colors': ['C'],
6869
reporter: ['R'],

lib/cli/run.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ exports.builder = yargs =>
8282
description: 'Show diff on failure',
8383
group: GROUPS.OUTPUT
8484
},
85-
exclude: {
85+
ignore: {
8686
defaultDescription: '(none)',
8787
description: 'Ignore file(s) or glob pattern(s)',
8888
group: GROUPS.FILES,

test/integration/fixtures/options/exclude/fail.fixture.js renamed to test/integration/fixtures/options/ignore/fail.fixture.js

File renamed without changes.

test/integration/fixtures/options/exclude/nested/fail.fixture.js renamed to test/integration/fixtures/options/ignore/nested/fail.fixture.js

File renamed without changes.

test/integration/fixtures/options/exclude/nested/pass.fixture.js renamed to test/integration/fixtures/options/ignore/nested/pass.fixture.js

File renamed without changes.

test/integration/fixtures/options/exclude/pass.fixture.js renamed to test/integration/fixtures/options/ignore/pass.fixture.js

File renamed without changes.
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var helpers = require('../helpers');
55
var runMochaJSON = helpers.runMochaJSON;
66
var resolvePath = helpers.resolveFixturePath;
77

8-
describe('--exclude', function() {
8+
describe('--ignore', function() {
99
/*
1010
* Runs mocha in {path} with the given args.
1111
* Calls handleResult with the result.
@@ -26,11 +26,11 @@ describe('--exclude', function() {
2626
});
2727
}
2828

29-
it('should exclude specific files', function(done) {
30-
var fixtures = path.join('options', 'exclude', '*');
29+
it('should ignore specific files', function(done) {
30+
var fixtures = path.join('options', 'ignore', '*');
3131
runMochaTest(
3232
fixtures,
33-
['--exclude', resolvePath(path.join('options', 'exclude', 'fail'))],
33+
['--ignore', resolvePath(path.join('options', 'ignore', 'fail'))],
3434
function(res) {
3535
expect(res, 'to have passed')
3636
.and('to have run test', 'should find this test')
@@ -40,11 +40,11 @@ describe('--exclude', function() {
4040
);
4141
});
4242

43-
it('should exclude globbed files', function(done) {
44-
var fixtures = path.join('options', 'exclude', '**', '*');
43+
it('should ignore globbed files', function(done) {
44+
var fixtures = path.join('options', 'ignore', '**', '*');
4545
runMochaTest(
4646
fixtures,
47-
['--exclude', '**/fail.fixture.js'],
47+
['--ignore', '**/fail.fixture.js'],
4848
function(res) {
4949
expect(res, 'to have passed')
5050
.and('not to have pending tests')
@@ -54,15 +54,15 @@ describe('--exclude', function() {
5454
);
5555
});
5656

57-
it('should exclude multiple patterns', function(done) {
58-
var fixtures = path.join('options', 'exclude', '**', '*');
57+
it('should ignore multiple patterns', function(done) {
58+
var fixtures = path.join('options', 'ignore', '**', '*');
5959
runMochaTest(
6060
fixtures,
6161
[
62-
'--exclude',
63-
resolvePath(path.join('options', 'exclude', 'fail')),
64-
'--exclude',
65-
resolvePath(path.join('options', 'exclude', 'nested', 'fail'))
62+
'--ignore',
63+
resolvePath(path.join('options', 'ignore', 'fail')),
64+
'--ignore',
65+
resolvePath(path.join('options', 'ignore', 'nested', 'fail'))
6666
],
6767
function(res) {
6868
expect(res, 'to have passed')

0 commit comments

Comments
 (0)