@@ -164,6 +164,34 @@ describe('PathMatcher', () => {
164164 expect ( results ) . to . not . include ( targets [ 4 ] , 'Path wrongly included' ) ;
165165 } ) ;
166166 } ) ;
167+
168+ describe ( 'Hidden dot folders' , ( ) => {
169+ it ( 'When projectDir contains a .dotFolder then the files underneath it are not matched' , async ( ) => {
170+ const pm : PathMatcher = new PathMatcher ( [ '**/*.js' , '/some/projectFolder/**/*.cls' ] , '/some/projectFolder' ) ;
171+ const targets : string [ ] = [
172+ '/some/projectFolder/subFolder/.dotFolder/a.js' ,
173+ '/some/projectFolder/subFolder/nonDotFolder/b.js' ,
174+ '/some/projectFolder/subFolder/.dotFolder/c.cls' ,
175+ '/some/projectFolder/subFolder/nonDotFolder/d.cls'
176+ ] ;
177+
178+ const results : string [ ] = await pm . filterPathsByPatterns ( targets ) ;
179+ expect ( results ) . to . deep . equal ( [ targets [ 1 ] , targets [ 3 ] ] ) ;
180+ } ) ;
181+
182+ it ( 'When projectDir is under a .dotFolder then the projectDir is not excluded' , async ( ) => {
183+ const pm : PathMatcher = new PathMatcher ( [ '**/*.js' , '/some/.dotFolder/projectFolder/**/*.cls' ] , '/some/.dotFolder/projectFolder' ) ;
184+ const targets : string [ ] = [
185+ '/some/.dotFolder/projectFolder/subFolder/.dotFolder/a.js' ,
186+ '/some/.dotFolder/projectFolder/subFolder/nonDotFolder/b.js' ,
187+ '/some/.dotFolder/projectFolder/subFolder/.dotFolder/c.cls' ,
188+ '/some/.dotFolder/projectFolder/subFolder/nonDotFolder/d.cls'
189+ ] ;
190+
191+ const results : string [ ] = await pm . filterPathsByPatterns ( targets ) ;
192+ expect ( results ) . to . deep . equal ( [ targets [ 1 ] , targets [ 3 ] ] ) ;
193+ } ) ;
194+ } ) ;
167195 } ) ;
168196
169197 describe ( '#pathMatchesPatterns()' , ( ) => {
@@ -263,6 +291,38 @@ describe('PathMatcher', () => {
263291 it ( 'DOES NOT MATCH paths matching negative patterns but not positive patterns' , async ( ) => {
264292 expect ( await pm . pathMatchesPatterns ( targets [ 4 ] ) ) . to . equal ( false , 'Path wrongly not matched.' ) ;
265293 } ) ;
266- } )
267- } )
294+ } ) ;
295+
296+ describe ( 'Hidden dot folders' , ( ) => {
297+ it ( 'When projectDir contains a .dotFolder then the files underneath it are not matched' , async ( ) => {
298+ const pm : PathMatcher = new PathMatcher ( [ '**/*.js' , '/some/projectFolder/**/*.cls' ] , '/some/projectFolder' ) ;
299+ const targets : string [ ] = [
300+ '/some/projectFolder/subFolder/.dotFolder/a.js' ,
301+ '/some/projectFolder/subFolder/nonDotFolder/b.js' ,
302+ '/some/projectFolder/subFolder/.dotFolder/c.cls' ,
303+ '/some/projectFolder/subFolder/nonDotFolder/d.cls'
304+ ] ;
305+
306+ expect ( await pm . pathMatchesPatterns ( targets [ 0 ] ) ) . to . equal ( false ) ;
307+ expect ( await pm . pathMatchesPatterns ( targets [ 1 ] ) ) . to . equal ( true ) ;
308+ expect ( await pm . pathMatchesPatterns ( targets [ 2 ] ) ) . to . equal ( false ) ;
309+ expect ( await pm . pathMatchesPatterns ( targets [ 3 ] ) ) . to . equal ( true ) ;
310+ } ) ;
311+
312+ it ( 'When projectDir is under a .dotFolder then the projectDir is not excluded' , async ( ) => {
313+ const pm : PathMatcher = new PathMatcher ( [ '**/*.js' , '/some/.dotFolder/projectFolder/**/*.cls' ] , '/some/.dotFolder/projectFolder/' ) ;
314+ const targets : string [ ] = [
315+ '/some/.dotFolder/projectFolder/.dotFolder/a.js' ,
316+ '/some/.dotFolder/projectFolder/nonDotFolder/b.js' ,
317+ '/some/.dotFolder/projectFolder/.dotFolder/c.cls' ,
318+ '/some/.dotFolder/projectFolder/nonDotFolder/d.cls'
319+ ] ;
320+
321+ expect ( await pm . pathMatchesPatterns ( targets [ 0 ] ) ) . to . equal ( false ) ;
322+ expect ( await pm . pathMatchesPatterns ( targets [ 1 ] ) ) . to . equal ( true ) ;
323+ expect ( await pm . pathMatchesPatterns ( targets [ 2 ] ) ) . to . equal ( false ) ;
324+ expect ( await pm . pathMatchesPatterns ( targets [ 3 ] ) ) . to . equal ( true ) ;
325+ } ) ;
326+ } ) ;
327+ } ) ;
268328} ) ;
0 commit comments