Skip to content

Commit 09dc65a

Browse files
isabellahochstainless-app[bot]
authored andcommitted
clean up custom helper functions (#8)
* create helpers * export helpers * update deps * fix typing errors in helpers
1 parent 9948b2c commit 09dc65a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/lib/helpers.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from 'fs';
22
import path from 'path';
33
import { glob } from 'glob';
4+
import minimatch from 'minimatch';
45

56
export interface FileData {
67
path: string;
@@ -20,6 +21,7 @@ const DEFAULT_IGNORE = [
2021
'build/**',
2122
'.next/**',
2223
'coverage/**',
24+
'**/__tests__/**',
2325
'**/.env*'
2426
];
2527

@@ -35,12 +37,11 @@ export async function collectFiles(
3537

3638
const allFilePaths: string[] = [];
3739
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);
4445
}
4546

4647
const filePaths = [...new Set(allFilePaths)];
@@ -49,11 +50,11 @@ export async function collectFiles(
4950

5051
for (const filePath of filePaths) {
5152
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()) {
5455
files.push({
5556
path: filePath,
56-
content
57+
contents
5758
});
5859
}
5960
} catch {

0 commit comments

Comments
 (0)