Skip to content

Commit bdbeb64

Browse files
committed
Add support for --ignore-pattern
1 parent 07807e0 commit bdbeb64

File tree

5 files changed

+82
-46
lines changed

5 files changed

+82
-46
lines changed

lib/options.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function options(flags, configuration) {
3535
}
3636
})
3737

38-
ext = extensions(config.ext)
38+
ext = commaSeparated(config.ext)
3939
report = reporter(config.report)
4040

4141
help = [
@@ -77,6 +77,7 @@ function options(flags, configuration) {
7777
settings: settings(config.setting),
7878
ignoreName: configuration.ignoreName,
7979
ignorePath: config.ignorePath,
80+
ignorePatterns: commaSeparated(config.ignorePattern),
8081
detectIgnore: config.ignore,
8182
pluginPrefix: configuration.pluginPrefix,
8283
plugins: plugins(config.use),
@@ -104,7 +105,7 @@ function addEach(option) {
104105
}
105106

106107
// Parse `extensions`.
107-
function extensions(value) {
108+
function commaSeparated(value) {
108109
return flatten(normalize(value).map(splitList))
109110
}
110111

lib/schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@
101101
"type": "string",
102102
"value": "<path>"
103103
},
104+
{
105+
"long": "ignore-pattern",
106+
"description": "specify ignore patterns",
107+
"type": "string",
108+
"value": "<globs>"
109+
},
104110
{
105111
"long": "tree-in",
106112
"description": "specify input as syntax tree",

test/fixtures/example/HELP

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,29 @@ Usage: foo [options] [path | glob ...]
44

55
Options:
66

7-
-h --help output usage information
8-
-v --version output version number
9-
-o --output [path] specify output location
10-
-r --rc-path <path> specify configuration file
11-
-i --ignore-path <path> specify ignore file
12-
-s --setting <settings> specify settings
13-
-e --ext <extensions> specify extensions
14-
-u --use <plugins> use plugins
15-
-w --watch watch for changes and reprocess
16-
-q --quiet output only warnings and errors
17-
-S --silent output only errors
18-
-f --frail exit with 1 on warnings
19-
-t --tree specify input and output as syntax tree
20-
--report <reporter> specify reporter
21-
--file-path <path> specify path to process as
22-
--tree-in specify input as syntax tree
23-
--tree-out output syntax tree
24-
--inspect output formatted syntax tree
25-
--[no-]stdout specify writing to stdout (on by default)
26-
--[no-]color specify color in report (on by default)
27-
--[no-]config search for configuration files (on by default)
28-
--[no-]ignore search for ignore files (on by default)
7+
-h --help output usage information
8+
-v --version output version number
9+
-o --output [path] specify output location
10+
-r --rc-path <path> specify configuration file
11+
-i --ignore-path <path> specify ignore file
12+
-s --setting <settings> specify settings
13+
-e --ext <extensions> specify extensions
14+
-u --use <plugins> use plugins
15+
-w --watch watch for changes and reprocess
16+
-q --quiet output only warnings and errors
17+
-S --silent output only errors
18+
-f --frail exit with 1 on warnings
19+
-t --tree specify input and output as syntax tree
20+
--report <reporter> specify reporter
21+
--file-path <path> specify path to process as
22+
--ignore-pattern <globs> specify ignore patterns
23+
--tree-in specify input as syntax tree
24+
--tree-out output syntax tree
25+
--inspect output formatted syntax tree
26+
--[no-]stdout specify writing to stdout (on by default)
27+
--[no-]color specify color in report (on by default)
28+
--[no-]config search for configuration files (on by default)
29+
--[no-]ignore search for ignore files (on by default)
2930

3031
Examples:
3132

test/fixtures/example/LONG_FLAG

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
Error: Unknown option `--no`, expected:
2-
-h --help output usage information
3-
-v --version output version number
4-
-o --output [path] specify output location
5-
-r --rc-path <path> specify configuration file
6-
-i --ignore-path <path> specify ignore file
7-
-s --setting <settings> specify settings
8-
-e --ext <extensions> specify extensions
9-
-u --use <plugins> use plugins
10-
-w --watch watch for changes and reprocess
11-
-q --quiet output only warnings and errors
12-
-S --silent output only errors
13-
-f --frail exit with 1 on warnings
14-
-t --tree specify input and output as syntax tree
15-
--report <reporter> specify reporter
16-
--file-path <path> specify path to process as
17-
--tree-in specify input as syntax tree
18-
--tree-out output syntax tree
19-
--inspect output formatted syntax tree
20-
--[no-]stdout specify writing to stdout (on by default)
21-
--[no-]color specify color in report (on by default)
22-
--[no-]config search for configuration files (on by default)
23-
--[no-]ignore search for ignore files (on by default)
2+
-h --help output usage information
3+
-v --version output version number
4+
-o --output [path] specify output location
5+
-r --rc-path <path> specify configuration file
6+
-i --ignore-path <path> specify ignore file
7+
-s --setting <settings> specify settings
8+
-e --ext <extensions> specify extensions
9+
-u --use <plugins> use plugins
10+
-w --watch watch for changes and reprocess
11+
-q --quiet output only warnings and errors
12+
-S --silent output only errors
13+
-f --frail exit with 1 on warnings
14+
-t --tree specify input and output as syntax tree
15+
--report <reporter> specify reporter
16+
--file-path <path> specify path to process as
17+
--ignore-pattern <globs> specify ignore patterns
18+
--tree-in specify input as syntax tree
19+
--tree-out output syntax tree
20+
--inspect output formatted syntax tree
21+
--[no-]stdout specify writing to stdout (on by default)
22+
--[no-]color specify color in report (on by default)
23+
--[no-]config search for configuration files (on by default)
24+
--[no-]ignore search for ignore files (on by default)

test/index.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,33 @@ test('unified-args', function(t) {
456456
}
457457
})
458458

459+
t.test('should support `--ignore-pattern`', function(st) {
460+
var expected = [
461+
'alpha.text: no issues found',
462+
'bravo.text: no issues found',
463+
'one.txt: no issues found',
464+
'two.txt: no issues found'
465+
].join('\n')
466+
467+
st.plan(1)
468+
469+
execa(bin, [
470+
'.',
471+
'--ext',
472+
'txt,text',
473+
'--ignore-pattern',
474+
'charlie/*,three/*.txt'
475+
]).then(onsuccess, st.fail)
476+
477+
function onsuccess(res) {
478+
st.deepEqual(
479+
[res.stdout, strip(res.stderr)],
480+
['', expected],
481+
'should work'
482+
)
483+
}
484+
})
485+
459486
t.test('should honour `--watch`', function(st) {
460487
var expected = [
461488
'Watching... (press CTRL+C to exit)',

0 commit comments

Comments
 (0)