(directoryPath: string)
| 5 | |
| 6 | // Read directories and processes blocks.ts files |
| 7 | const 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 | |
| 39 | const generateBlockJSON = async (directoryPath: string): Promise<Map<string, string> | undefined> => { |
| 40 | // Check if block.ts file exists |
no test coverage detected