forked from yamadashy/repomix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'includefiles' into feature/include
# Conflicts: # src/cli/index.ts # src/core/packager.ts
- Loading branch information
Showing
7 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,6 @@ | |
"useGitignore": true, | ||
"useDefaultPatterns": true, | ||
"customPatterns": [] | ||
} | ||
}, | ||
"includeFiles": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import path from 'path'; | ||
import { logger } from '../utils/logger.js'; | ||
|
||
export function filterIncludedFiles(rootDir: string, filePaths: string[], include: string[]): string[] { | ||
if (include.length === 0) { | ||
return filePaths; | ||
} | ||
|
||
// Normalize paths to handle case insensitivity and different representations | ||
const normalizePath = (p: string) => path.normalize(path.resolve(rootDir, p)).toLowerCase(); | ||
|
||
// Create a Set of normalized absolute paths for the included files | ||
const includeSet = new Set(include.map(normalizePath)); | ||
|
||
// Map file paths to their normalized absolute paths and filter those that are in the include set | ||
const filteredAbsolutePaths = filePaths | ||
.map(filePath => path.resolve(rootDir, filePath)) | ||
.filter(absolutePath => includeSet.has(normalizePath(absolutePath))); | ||
|
||
// Log any files in includeSet that are not found in filePaths | ||
const absoluteFilePathsSet = new Set(filePaths.map(filePath => normalizePath(path.resolve(rootDir, filePath)))); | ||
const missingFiles = [...includeSet].filter(includedFile => !absoluteFilePathsSet.has(includedFile)); | ||
if (missingFiles.length > 0) { | ||
logger.trace(`Included files not found: ${missingFiles.join(', ')}`); | ||
} | ||
|
||
// Convert filtered absolute paths back to relative paths | ||
return filteredAbsolutePaths.map(filePath => path.relative(rootDir, filePath)); | ||
} |