mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
* Add a zig fmt action * add failing file * Setup prettier better * Update prettier-fmt.yml * Fail on error * Update prettier-fmt.yml * boop * boop2 * tar.gz * Update zig-fmt.yml * Update zig-fmt.yml * Update zig-fmt.yml * Update zig-fmt.yml * Update zig-fmt.yml * boop * Update prettier-fmt.yml * tag * newlines * multiline * fixup * Update zig-fmt.yml * update it * fixup * both * w * Update prettier-fmt.yml * prettier all the things * Update package.json * zig fmt * ❌ ✅ * bump * . * quotes * fix prettier ignore * once more * Update prettier-fmt.yml * Update fallback.ts * consistentcy --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
const json = await (await fetch("https://raw.githubusercontent.com/jshttp/mime-db/master/db.json")).json();
|
|
|
|
json["application/javascript"].extensions.push(`ts`, `tsx`, `mts`, `mtsx`, `cts`, `cjs`, `mjs`, `js`);
|
|
|
|
delete json["application/node"];
|
|
delete json["application/deno"];
|
|
delete json["application/wasm"];
|
|
|
|
var categories = new Set();
|
|
var all = "pub const all = struct {";
|
|
for (let key of Object.keys(json).sort()) {
|
|
const [category] = key.split("/");
|
|
categories.add(category);
|
|
all += `pub const @"${key}": MimeType = MimeType{.category = .@"${category}", .value = "${key}"};\n`;
|
|
}
|
|
|
|
const withExtensions = [
|
|
...new Set([
|
|
...Object.keys(json)
|
|
.filter(key => {
|
|
return !!json[key]?.extensions?.length;
|
|
})
|
|
.flatMap(mime => {
|
|
return [...new Set([...json[mime].extensions])].map(ext => {
|
|
return [`.{.@"${ext}", all.@"${mime}"}`];
|
|
});
|
|
})
|
|
.sort(),
|
|
]),
|
|
];
|
|
|
|
all += "\n";
|
|
|
|
all += ` pub const extensions = ComptimeStringMap(MimeType, .{
|
|
${withExtensions.join(",\n")},
|
|
});
|
|
};`;
|
|
|
|
all += "\n";
|
|
|
|
// all += `pub const Category = enum {
|
|
// ${[...categories].map((a) => `@"${a}"`).join(", \n")}
|
|
// };
|
|
// `;
|
|
|
|
console.log(all);
|