@@ -6,6 +6,14 @@ describe('createIsIgnored', () => {
6
6
const distModulePath = '/path/to/dist/foo.js' ;
7
7
const srcModulePath = '/path/to/src/foo.ts' ;
8
8
9
+ it ( 'should handle built-in ignored directories' , ( ) => {
10
+ const customPath = '/path/without/git/or/node_modules' ;
11
+ const isIgnored = createIsIgnored ( [ ] , [ ] ) ;
12
+ expect ( isIgnored ( gitPath ) ) . toBe ( true ) ;
13
+ expect ( isIgnored ( customPath ) ) . toBe ( false ) ;
14
+ expect ( isIgnored ( '/path/to/.github/foo' ) ) . toBe ( false ) ;
15
+ } ) ;
16
+
9
17
it ( 'should allow to passing RegExp to the first argument' , ( ) => {
10
18
const isIgnored = createIsIgnored ( [ / [ \\ / ] (?: \. g i t | n o d e _ m o d u l e s ) [ \\ / ] / ] , [ ] ) ;
11
19
expect ( isIgnored ( gitPath ) ) . toBe ( true ) ;
@@ -52,5 +60,34 @@ describe('createIsIgnored', () => {
52
60
expect ( isIgnored3 ( nodeModulesPath ) ) . toBe ( true ) ;
53
61
expect ( isIgnored3 ( distModulePath ) ) . toBe ( true ) ;
54
62
expect ( isIgnored3 ( srcModulePath ) ) . toBe ( false ) ;
63
+
64
+ // exclude: ["**/dist"] in tsconfig.json
65
+ const isIgnored4 = createIsIgnored ( [ ] , [ '/path/to/**/dist' ] ) ;
66
+ expect ( isIgnored4 ( gitPath ) ) . toBe ( true ) ;
67
+ expect ( isIgnored4 ( nodeModulesPath ) ) . toBe ( true ) ;
68
+ expect ( isIgnored4 ( distModulePath ) ) . toBe ( true ) ;
69
+ expect ( isIgnored4 ( srcModulePath ) ) . toBe ( false ) ;
70
+
71
+ // exclude: ["**/dist/"] in tsconfig.json
72
+ const isIgnored5 = createIsIgnored ( [ ] , [ '/path/to/**/dist/' ] ) ;
73
+ expect ( isIgnored5 ( gitPath ) ) . toBe ( true ) ;
74
+ expect ( isIgnored5 ( nodeModulesPath ) ) . toBe ( true ) ;
75
+ expect ( isIgnored5 ( distModulePath ) ) . toBe ( true ) ;
76
+ expect ( isIgnored5 ( srcModulePath ) ) . toBe ( false ) ;
77
+
78
+ // exclude: ["dist/**/*"] in tsconfig.json
79
+ const isIgnored6 = createIsIgnored ( [ ] , [ '/path/to/dist/**/*' ] ) ;
80
+ expect ( isIgnored6 ( gitPath ) ) . toBe ( true ) ;
81
+ expect ( isIgnored6 ( nodeModulesPath ) ) . toBe ( false ) ;
82
+ expect ( isIgnored6 ( distModulePath ) ) . toBe ( true ) ;
83
+ expect ( isIgnored6 ( srcModulePath ) ) . toBe ( false ) ;
84
+ } ) ;
85
+
86
+ it ( 'should combine multiple ignore patterns' , ( ) => {
87
+ const isIgnored = createIsIgnored ( [ / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] / ] , [ '/path/to/dist' ] ) ;
88
+ expect ( isIgnored ( gitPath ) ) . toBe ( true ) ;
89
+ expect ( isIgnored ( nodeModulesPath ) ) . toBe ( true ) ;
90
+ expect ( isIgnored ( distModulePath ) ) . toBe ( true ) ;
91
+ expect ( isIgnored ( srcModulePath ) ) . toBe ( false ) ;
55
92
} ) ;
56
93
} ) ;
0 commit comments