(dir)
| 44 | |
| 45 | /** @type {(dir: string) => Promise<void>} */ |
| 46 | const walk = async (dir) => { |
| 47 | const dirFiles = []; |
| 48 | const dirDirs = []; |
| 49 | const paths = await fs.readdir(dir); |
| 50 | for (const path of paths) { |
| 51 | const stat = await fs.stat(`${dir}/${path}`); |
| 52 | if (stat.isDirectory()) { |
| 53 | dirDirs.push(path); |
| 54 | } else { |
| 55 | dirFiles.push(path); |
| 56 | } |
| 57 | } |
| 58 | const localeFiles = dirFiles.filter((f) => f.split('.').at(-2) === code); |
| 59 | for (const localeFile of localeFiles) { |
| 60 | const messages = await localeFileToJson(`${dir}/${localeFile}`); |
| 61 | result = {...result, ...messages}; |
| 62 | } |
| 63 | for (const folder of dirDirs) { |
| 64 | await walk(`${dir}/${folder}`); |
| 65 | } |
| 66 | }; |
| 67 | |
| 68 | await walk(localesDir); |
| 69 | return JSON.stringify(result, null, 4); |
no test coverage detected