MCPcopy
hub / github.com/github/docs / createCheckContentDirectory

Function createCheckContentDirectory

src/rest/scripts/test-open-api-schema.js:78–106  ·  view source on GitHub ↗
(contentFiles)

Source from the content-addressed store, hash-verified

76}
77
78async 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
108function isApiVersioned(version) {
109 return allVersions[version] && allVersions[version].apiVersions.length > 0

Callers 1

Calls 4

createCheckObjFunction · 0.85
frontmatterFunction · 0.85
getApplicableVersionsFunction · 0.85
isApiVersionedFunction · 0.70

Tested by

no test coverage detected