Skip to content

Commit

Permalink
fixup! fix: Use git attributes to identify binary files
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinbyrne committed Oct 24, 2024
1 parent 190762d commit ec4f9d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/cli/src/fulltext/FileIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,9 @@ const DATA_FILE_EXTENSIONS: string[] = [
'xml',
].map((ext) => '.' + ext);

const isBinaryFile = (fileName: string, gitAttributes?: ReturnType<typeof getGitAttributes>) => {
if (BINARY_FILE_EXTENSIONS.some((ext) => fileName.endsWith(ext))) return true;
if (gitAttributes?.some((attr) => attr.binary && minimatch(fileName, attr.pattern))) return true;
return false;
};
const isBinaryFile = (fileName: string, gitAttributes?: ReturnType<typeof getGitAttributes>) =>
BINARY_FILE_EXTENSIONS.some((ext) => fileName.endsWith(ext)) ||
gitAttributes?.some((attr) => attr.binary && minimatch(fileName, attr.pattern, { dot: true }));

const isDataFile = (fileName: string) => {
return DATA_FILE_EXTENSIONS.some((ext) => fileName.endsWith(ext));
Expand Down
1 change: 1 addition & 0 deletions packages/cli/tests/unit/fulltext/FileIndex.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ describe(filterFiles, () => {
writeFileSync(join(dir, 'file.txt'), 'hello');
writeFileSync(join(dir, 'file.my-extension'), 'hello');
writeFileSync(join(dir, 'file.bin'), 'hello');
writeFileSync(join(dir, '.file.bin'), 'hello');

const fileList = readdirSync(dir);
const gitAttributes = getGitAttributes(dir);
Expand Down

0 comments on commit ec4f9d8

Please sign in to comment.