()
| 68 | main().catch(console.error); |
| 69 | |
| 70 | async function parseContentDir() { |
| 71 | const rootDir = await packageDirectory(); |
| 72 | const contentURL = `${rootDir}/content`; |
| 73 | const rootSectionNames = await fs.readdir(contentURL); |
| 74 | |
| 75 | function dirNameToTitle(dirName) { |
| 76 | return capitalize(dirName.split("-").splice(1).join(" ")); |
| 77 | } |
| 78 | |
| 79 | function capitalize(string) { |
| 80 | return string.charAt(0).toUpperCase() + string.slice(1); |
| 81 | } |
| 82 | |
| 83 | const rootSections = []; |
| 84 | |
| 85 | for (const rootSectionName of rootSectionNames) { |
| 86 | const sectionPath = `${contentURL}/${rootSectionName}`; |
| 87 | const sections = []; |
| 88 | const subSectionDirNames = await fs.readdir(sectionPath); |
| 89 | |
| 90 | for (const dirName of subSectionDirNames) { |
| 91 | const path = `${sectionPath}/${dirName}`; |
| 92 | |
| 93 | const frameworkDirs = await fs.readdir(path); |
| 94 | const frameworkSections = []; |
| 95 | for (const frameworkDir of frameworkDirs) { |
| 96 | const frameworkPath = `${path}/${frameworkDir}`; |
| 97 | const files = []; |
| 98 | const fileNames = await fs.readdir(`${frameworkPath}`); |
| 99 | |
| 100 | for (const fileName of fileNames) { |
| 101 | const filePath = `${frameworkPath}/${fileName}`; |
| 102 | const ext = nodePath.parse(filePath).ext.split(".").pop(); |
| 103 | files.push({ |
| 104 | path: filePath, |
| 105 | fileName, |
| 106 | ext, |
| 107 | //content: await fs.readFile(filePath, 'utf-8'), |
| 108 | }); |
| 109 | } |
| 110 | |
| 111 | frameworkSections.push({ |
| 112 | dirName: frameworkDir, |
| 113 | path: frameworkPath, |
| 114 | files, |
| 115 | }); |
| 116 | } |
| 117 | |
| 118 | const title = dirNameToTitle(dirName); |
| 119 | sections.push({ |
| 120 | id: kebabCase(title), |
| 121 | path, |
| 122 | dirName, |
| 123 | title, |
| 124 | children: frameworkSections, |
| 125 | }); |
| 126 | } |
| 127 |
no test coverage detected