* Orchestrates the process of reading component status for each file in the given directory. * * @param dir Directory to source files where status will be extracted from * @returns A promise that resolves to an object containing component statuses
(dir: string)
| 60 | * @returns A promise that resolves to an object containing component statuses |
| 61 | */ |
| 62 | async function readFiles(dir: string) { |
| 63 | try { |
| 64 | const dirContents = fs.readdirSync(dir, {withFileTypes: true}) |
| 65 | const filenames = dirContents.filter(dirent => dirent.isFile()).map(dirent => dirent.name) |
| 66 | const componentStatuses = await getComponentStatuses(filenames, dir) |
| 67 | |
| 68 | return componentStatuses |
| 69 | .filter(Boolean) |
| 70 | .reverse() |
| 71 | .reduce( |
| 72 | (acc, file) => ({ |
| 73 | ...acc, |
| 74 | ...file, |
| 75 | }), |
| 76 | {}, |
| 77 | ) |
| 78 | } catch (err) { |
| 79 | throw new Error(`error reading files: ${err}`) |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Writes the component status to the given file. |
no test coverage detected