File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change 1
1
import fs from 'fs' ;
2
2
import path from 'path' ;
3
3
import { glob } from 'glob' ;
4
+ import minimatch from 'minimatch' ;
4
5
5
6
export interface FileData {
6
7
path : string ;
@@ -20,6 +21,7 @@ const DEFAULT_IGNORE = [
20
21
'build/**' ,
21
22
'.next/**' ,
22
23
'coverage/**' ,
24
+ '**/__tests__/**' ,
23
25
'**/.env*'
24
26
] ;
25
27
@@ -35,12 +37,11 @@ export async function collectFiles(
35
37
36
38
const allFilePaths : string [ ] = [ ] ;
37
39
for ( const pattern of patterns ) {
38
- const filePaths = await glob ( pattern , {
39
- ignore,
40
- nodir : true ,
41
- absolute : false
42
- } ) ;
43
- allFilePaths . push ( ...filePaths ) ;
40
+ const globResult = glob . sync ( pattern , { nodir : true } ) ;
41
+ const filtered = globResult . filter ( ( match : string ) =>
42
+ ! ignore . some ( ignorePattern => minimatch ( match , ignorePattern ) )
43
+ ) ;
44
+ allFilePaths . push ( ...filtered ) ;
44
45
}
45
46
46
47
const filePaths = [ ...new Set ( allFilePaths ) ] ;
@@ -49,11 +50,11 @@ export async function collectFiles(
49
50
50
51
for ( const filePath of filePaths ) {
51
52
try {
52
- const content = fs . readFileSync ( path . resolve ( basePath , filePath ) , 'utf8' ) ;
53
- if ( content . trim ( ) ) {
53
+ const contents = fs . readFileSync ( path . resolve ( basePath , filePath ) , 'utf8' ) ;
54
+ if ( contents . trim ( ) ) {
54
55
files . push ( {
55
56
path : filePath ,
56
- content
57
+ contents
57
58
} ) ;
58
59
}
59
60
} catch {
You can’t perform that action at this time.
0 commit comments