(dir: string)
| 3 | import * as path from 'pathe'; |
| 4 | |
| 5 | const getAllFiles = async (dir: string): Promise<string[]> => { |
| 6 | const dirents = await fs.readdir(dir, { withFileTypes: true }); |
| 7 | const files = await Promise.all( |
| 8 | dirents.map(async (dirent) => { |
| 9 | // If file is package.json, do not include |
| 10 | if (dirent.name === 'package.json') { |
| 11 | return []; |
| 12 | } |
| 13 | // Ignore .woff and .woff2 files |
| 14 | if (dirent.name.endsWith('.woff') || dirent.name.endsWith('.woff2')) { |
| 15 | return []; |
| 16 | } |
| 17 | const res = path.resolve(dir, dirent.name); |
| 18 | return dirent.isDirectory() ? await getAllFiles(res) : res; |
| 19 | }), |
| 20 | ); |
| 21 | |
| 22 | return Array.prototype.concat(...files); |
| 23 | }; |
| 24 | |
| 25 | const getHash = async (dir: string): Promise<string> => { |
| 26 | const files = await getAllFiles(dir); |
no outgoing calls
no test coverage detected