| author | |
| committer | |
| log | 67f640093ffea1adaa585949d87e4bc2010b0810 |
| tree | d3afc60d77bbde83c0550bc9129a5f0c2ff5fa67 |
| parent | 10ac2f2ba495508a2a2fd469e67eda5df73f0df1 |
| signature | Signed by PGP key B5690EEEBB952194 |
2 files changed, 14 insertions(+), 2 deletions(-)
apps/web/src/pierre-icons.test.ts+5| ... | ... | @@ -56,7 +56,12 @@ describe("Pierre file icons", () => { |
| 56 | 56 | |
| 57 | 57 | it("normalizes common markdown fence language aliases", () => { |
| 58 | 58 | assert.equal(syntheticFileNameForLanguageId("typescript"), "file.ts"); |
| 59 | assert.equal(syntheticFileNameForLanguageId("dockerfile"), "Dockerfile"); | |
| 59 | 60 | assert.equal(syntheticFileNameForLanguageId("shellscript"), "file.sh"); |
| 60 | 61 | assert.equal(syntheticFileNameForLanguageId("python"), "file.py"); |
| 61 | 62 | }); |
| 63 | ||
| 64 | it("gives a dockerfile fence the Docker icon", () => { | |
| 65 | assert.isTrue(hasSpecificPierreIconForFileName(syntheticFileNameForLanguageId("dockerfile"))); | |
| 66 | }); | |
| 62 | 67 | }); |
apps/web/src/pierre-icons.ts+9-2| ... | ... | @@ -51,7 +51,6 @@ const completeIconResolver = createFileTreeIconResolver(T3_PIERRE_ICONS); |
| 51 | 51 | const LANGUAGE_EXTENSION_ALIASES: Record<string, string> = { |
| 52 | 52 | bash: "sh", |
| 53 | 53 | csharp: "cs", |
| 54 | dockerfile: "dockerfile", | |
| 55 | 54 | javascript: "js", |
| 56 | 55 | jsx: "jsx", |
| 57 | 56 | markdown: "md", |
| ... | ... | @@ -79,9 +78,17 @@ export function inferEntryKindFromPath(pathValue: string): "file" | "directory" |
| 79 | 78 | return base.includes(".") ? "file" : "directory"; |
| 80 | 79 | } |
| 81 | 80 | |
| 81 | /** Languages whose files are recognised by name rather than by extension. */ | |
| 82 | const LANGUAGE_FILE_NAMES: Record<string, string> = { | |
| 83 | dockerfile: "Dockerfile", | |
| 84 | }; | |
| 85 | ||
| 82 | 86 | export function syntheticFileNameForLanguageId(languageId: string): string { |
| 83 | 87 | const normalized = languageId.toLowerCase(); |
| 84 | return `file.${LANGUAGE_EXTENSION_ALIASES[normalized] ?? normalized}`; | |
| 88 | return ( | |
| 89 | LANGUAGE_FILE_NAMES[normalized] ?? | |
| 90 | `file.${LANGUAGE_EXTENSION_ALIASES[normalized] ?? normalized}` | |
| 91 | ); | |
| 85 | 92 | } |
| 86 | 93 | |
| 87 | 94 | export function resolvePierreIconForEntry( |