| 101 | } |
| 102 | |
| 103 | async function writeTypesFile(name: string, types: Record<string, string[]>) { |
| 104 | const dirpath = path.join(ROOT_DIR, '/types'); |
| 105 | const filepath = path.join(dirpath, `${name}.ts`); |
| 106 | await mkdir(dirpath, { recursive: true }); |
| 107 | |
| 108 | // Generate source content |
| 109 | let source = TYPES_TEMPLATE.replace(TYPES_MARKER, JSON.stringify(types)); |
| 110 | |
| 111 | // Format |
| 112 | source = await prettier.format(source, { |
| 113 | parser: 'typescript', |
| 114 | ...PRETTIER_OPTIONS, |
| 115 | }); |
| 116 | |
| 117 | await writeFile(filepath, source); |
| 118 | } |
| 119 | |
| 120 | async function main() { |
| 121 | const mimedb = await fetch(MIME_DB_URL).then((res) => { |