MCPcopy Index your code
hub / github.com/darkreader/darkreader / walk

Function walk

tasks/bundle-locales.js:46–66  ·  view source on GitHub ↗
(dir)

Source from the content-addressed store, hash-verified

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);

Callers 1

mergeLocaleFunction · 0.70

Calls 1

localeFileToJsonFunction · 0.85

Tested by

no test coverage detected