summaryrefslogtreecommitdiff
path: root/packages/core/src/utils/getFolderStructure.ts
diff options
context:
space:
mode:
authorAnas H. Sulaiman <[email protected]>2025-06-14 10:25:34 -0400
committerGitHub <[email protected]>2025-06-14 14:25:34 +0000
commit4873fce7919b4d74cee183a91fa8a3af58aef993 (patch)
treec08502c1e4592667160cb006528f868fd6283294 /packages/core/src/utils/getFolderStructure.ts
parente6d54771686b3f9537a5a05c9f9101afad3ffdcd (diff)
centralize file filtering in `FileDiscoveryService` (#1039)
Diffstat (limited to 'packages/core/src/utils/getFolderStructure.ts')
-rw-r--r--packages/core/src/utils/getFolderStructure.ts11
1 files changed, 7 insertions, 4 deletions
diff --git a/packages/core/src/utils/getFolderStructure.ts b/packages/core/src/utils/getFolderStructure.ts
index 7aee377b..6798a147 100644
--- a/packages/core/src/utils/getFolderStructure.ts
+++ b/packages/core/src/utils/getFolderStructure.ts
@@ -26,6 +26,8 @@ interface FolderStructureOptions {
fileIncludePattern?: RegExp;
/** For filtering files. */
fileService?: FileDiscoveryService;
+ /** Whether to use .gitignore patterns. */
+ respectGitIgnore?: boolean;
}
// Define a type for the merged options where fileIncludePattern remains optional
@@ -124,8 +126,8 @@ async function readFullStructure(
}
const fileName = entry.name;
const filePath = path.join(currentPath, fileName);
- if (options.fileService) {
- if (options.fileService.shouldIgnoreFile(filePath)) {
+ if (options.respectGitIgnore && options.fileService) {
+ if (options.fileService.shouldGitIgnoreFile(filePath)) {
continue;
}
}
@@ -159,8 +161,8 @@ async function readFullStructure(
const subFolderPath = path.join(currentPath, subFolderName);
let isIgnoredByGit = false;
- if (options?.fileService) {
- if (options.fileService.shouldIgnoreFile(subFolderPath)) {
+ if (options.respectGitIgnore && options.fileService) {
+ if (options.fileService.shouldGitIgnoreFile(subFolderPath)) {
isIgnoredByGit = true;
}
}
@@ -293,6 +295,7 @@ export async function getFolderStructure(
ignoredFolders: options?.ignoredFolders ?? DEFAULT_IGNORED_FOLDERS,
fileIncludePattern: options?.fileIncludePattern,
fileService: options?.fileService,
+ respectGitIgnore: options?.respectGitIgnore ?? true,
};
try {