MCPcopy Create free account
hub / github.com/ShaanCoding/makeread.me / readDirectoriesAndConvertToJSON

Function readDirectoriesAndConvertToJSON

backend/script/generate.ts:7–37  ·  view source on GitHub ↗
(directoryPath: string)

Source from the content-addressed store, hash-verified

5
6// Read directories and processes blocks.ts files
7const readDirectoriesAndConvertToJSON = async (directoryPath: string) => {
8 const directory: string = path.join(directoryPath, 'public')
9
10 fs.readdir(directory, (err, files) => {
11 if (err) {
12 console.error('Error reading root directory: ', err)
13 return
14 }
15
16 files.forEach((file) => {
17 const filePath = path.join(directory, file)
18 // Check if it is a directory
19 fs.stat(filePath, async (err, stats) => {
20 if (err) {
21 console.error('Error reading file stats: ', err)
22 return
23 }
24
25 if (stats.isDirectory()) {
26 const variableToUUIDMap: Map<string, string> | undefined = await generateBlockJSON(filePath)
27
28 if (!variableToUUIDMap) {
29 return
30 }
31
32 generateMacroJSON(filePath, variableToUUIDMap)
33 }
34 })
35 })
36 })
37}
38
39const generateBlockJSON = async (directoryPath: string): Promise<Map<string, string> | undefined> => {
40 // Check if block.ts file exists

Callers 1

generate.tsFile · 0.85

Calls 2

generateBlockJSONFunction · 0.85
generateMacroJSONFunction · 0.85

Tested by

no test coverage detected