File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 1
1
type Pathname = string
2
2
3
+ interface IgnoreRule {
4
+ pattern : string
5
+ mark ?: string
6
+ negative : boolean
7
+ }
8
+
3
9
interface TestResult {
4
10
ignored : boolean
5
11
unignored : boolean
12
+ rule ?: IgnoreRule
13
+ }
14
+
15
+ interface PatternParams {
16
+ pattern : string
17
+ mark ?: string
6
18
}
7
19
8
20
export interface Ignore {
@@ -11,7 +23,9 @@ export interface Ignore {
11
23
* @param {string[] } patterns
12
24
* @returns IgnoreBase
13
25
*/
14
- add ( patterns : string | Ignore | readonly ( string | Ignore ) [ ] ) : this
26
+ add (
27
+ patterns : string | Ignore | readonly ( string | Ignore ) [ ] | PatternParams
28
+ ) : this
15
29
16
30
/**
17
31
* Filters the given array of pathnames, and returns the filtered array.
@@ -40,6 +54,13 @@ export interface Ignore {
40
54
* @returns TestResult
41
55
*/
42
56
test ( pathname : Pathname ) : TestResult
57
+
58
+ /**
59
+ * Debugs ignore rules and returns the checking result, which is
60
+ * equivalent to `git check-ignore -v`.
61
+ * @returns TestResult
62
+ */
63
+ checkIgnore ( pathname : Pathname ) : TestResult
43
64
}
44
65
45
66
export interface Options {
Original file line number Diff line number Diff line change @@ -70,3 +70,15 @@ ignore({
70
70
ignoreCase : false ,
71
71
allowRelativePaths : true
72
72
} )
73
+
74
+ const ig7 = ignore ( )
75
+
76
+ ig7 . add ( { pattern : 'foo/*' , mark : '10' } )
77
+ const {
78
+ ignored : ignored7 ,
79
+ rule : ignoreRule7
80
+ } = ig7 . checkIgnore ( 'foo/' )
81
+
82
+ equal ( ignored7 , true , 'should ignore' )
83
+ equal ( ignoreRule7 . mark , '10' , 'mark is 10' )
84
+ equal ( ignoreRule7 . pattern , 'foo/*' , 'ignored by foo/*' )
You can’t perform that action at this time.
0 commit comments