Skip to content

Commit 9e23c31

Browse files
koki-developclaude
andcommitted
feat: Expand supported file extensions and sort alphabetically
Add support for more file types including shell scripts, configuration files, and various programming languages. Sort extensions alphabetically for better maintainability. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 6ec21d8 commit 9e23c31

File tree

1 file changed

+51
-29
lines changed

1 file changed

+51
-29
lines changed

src/lib/fileEditor.ts

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,59 @@ import { glob } from "glob";
55
import type { Diff, FileDiff } from "../components/types";
66
import { Git } from "./git";
77

8+
const textFileExtensions: string[] = [
9+
"bash",
10+
11+
"c",
12+
"cpp",
13+
"cs",
14+
"css",
15+
16+
"go",
17+
18+
"h",
19+
"hpp",
20+
"html",
21+
22+
"ini",
23+
24+
"java",
25+
"js",
26+
"json",
27+
"jsx",
28+
29+
"less",
30+
31+
"md",
32+
33+
"php",
34+
"py",
35+
36+
"rb",
37+
"rs",
38+
39+
"sass",
40+
"scss",
41+
"sql",
42+
"svg",
43+
44+
"toml",
45+
"ts",
46+
"tsx",
47+
"txt",
48+
49+
"xml",
50+
51+
"yaml",
52+
"yml",
53+
] as const;
54+
855
export class FileEditor {
956
private git = new Git();
1057
// Text file extension patterns
11-
// TODO: enhance these patterns
12-
private readonly textFilePatterns = [
13-
"**/*.txt",
14-
"**/*.md",
15-
"**/*.js",
16-
"**/*.jsx",
17-
"**/*.ts",
18-
"**/*.tsx",
19-
"**/*.json",
20-
"**/*.css",
21-
"**/*.html",
22-
"**/*.xml",
23-
"**/*.yml",
24-
"**/*.yaml",
25-
];
58+
private readonly textFilePatterns = textFileExtensions.map(
59+
(ext) => `**/*.${ext}`,
60+
);
2661

2762
// Cat word candidates
2863
private readonly catWords = [
@@ -57,20 +92,7 @@ export class FileEditor {
5792
*/
5893
private isTextFile(filePath: string): boolean {
5994
const extension = filePath.split(".").pop()?.toLowerCase();
60-
const textExtensions = [
61-
"txt",
62-
"md",
63-
"js",
64-
"ts",
65-
"tsx",
66-
"json",
67-
"css",
68-
"html",
69-
"xml",
70-
"yml",
71-
"yaml",
72-
];
73-
return textExtensions.includes(extension || "");
95+
return textFileExtensions.includes(extension || "");
7496
}
7597

7698
/**

0 commit comments

Comments
 (0)