(contentFiles)
| 76 | } |
| 77 | |
| 78 | async function createCheckContentDirectory(contentFiles) { |
| 79 | const checkContent = createCheckObj() |
| 80 | |
| 81 | for (const filename of contentFiles) { |
| 82 | const { data } = frontmatter(await fs.promises.readFile(filename, 'utf8')) |
| 83 | const applicableVersions = getApplicableVersions(data.versions, filename) |
| 84 | const splitPath = filename.split('/') |
| 85 | const subCategory = splitPath[splitPath.length - 1].replace('.md', '') |
| 86 | const category = |
| 87 | splitPath[splitPath.length - 2] === 'rest' ? subCategory : splitPath[splitPath.length - 2] |
| 88 | // All versions with appended calendar date versions if it exists |
| 89 | const allCompleteVersions = applicableVersions.flatMap((version) => { |
| 90 | return isApiVersioned(version) |
| 91 | ? allVersions[version].apiVersions.map( |
| 92 | (apiVersion) => `${allVersions[version].version}.${apiVersion}` |
| 93 | ) |
| 94 | : version |
| 95 | }) |
| 96 | |
| 97 | allCompleteVersions.forEach((version) => { |
| 98 | !checkContent[version][category] |
| 99 | ? (checkContent[version][category] = [subCategory]) |
| 100 | : checkContent[version][category].push(subCategory) |
| 101 | checkContent[version][category].sort() |
| 102 | }) |
| 103 | } |
| 104 | |
| 105 | return checkContent |
| 106 | } |
| 107 | |
| 108 | function isApiVersioned(version) { |
| 109 | return allVersions[version] && allVersions[version].apiVersions.length > 0 |
no test coverage detected