MCPcopy Index your code
hub / github.com/primer/react / readFiles

Function readFiles

script/component-status-project/build.ts:62–81  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

60 * @returns A promise that resolves to an object containing component statuses
61 */
62async 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.

Callers 1

buildFunction · 0.85

Calls 1

getComponentStatusesFunction · 0.85

Tested by

no test coverage detected