diff options
| author | Daniel Bannert <[email protected]> | 2022-04-08 17:27:28 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-04-08 15:27:28 +0000 |
| commit | 78a30fbdb8779a0e4b242d353a696672f64a1fcc (patch) | |
| tree | 9f373de465c54daa378bc5a8f18e8a8b50c3b04f /scripts | |
| parent | 7912cd0768c183bc3046074399852dc775280cb5 (diff) | |
| download | faker-78a30fbdb8779a0e4b242d353a696672f64a1fcc.tar.xz faker-78a30fbdb8779a0e4b242d353a696672f64a1fcc.zip | |
feat: updated mime-db to 1.52.0 (#808)
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/copyMimeTypes.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/scripts/copyMimeTypes.ts b/scripts/copyMimeTypes.ts new file mode 100644 index 00000000..9691070c --- /dev/null +++ b/scripts/copyMimeTypes.ts @@ -0,0 +1,39 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import type { Options } from 'prettier'; +import { format } from 'prettier'; +import options from '../.prettierrc.cjs'; + +const rootPath = path.resolve(__dirname, '..'); +const mimeDbPath = path.resolve(rootPath, 'node_modules/mime-db/db.json'); +const mimeDbLicencePath = path.resolve( + rootPath, + 'node_modules/mime-db/LICENSE' +); +const mimeTypesTsPath = path.resolve( + rootPath, + 'src/locales/en/system/mimeTypes.ts' +); +const prettierTsOptions: Options = { ...options, parser: 'typescript' }; +fs.readFile(mimeDbPath, 'utf8', (err, data) => { + if (err) { + throw err; + } + + const licence = fs.readFileSync(mimeDbLicencePath, { encoding: 'utf8' }); + const mimeTypeFileContent = `// This file is generated by scripts/copyMimeTypes.ts\n// Do not edit this file directly. Instead, update mime-db and run \`pnpm run copy:mime-types\`\n\n/*\n${ + licence as string + }*/\n\nexport default ${data as string};\n`; + + fs.writeFile( + mimeTypesTsPath, + format(mimeTypeFileContent, prettierTsOptions), + (err) => { + if (err) { + throw err; + } + + console.log(`Mime types copied to ${mimeTypesTsPath as string}`); + } + ); +}); |
