forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathremove-deprecated-frontmatter.js
22 lines (17 loc) · 1.03 KB
/
remove-deprecated-frontmatter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const { getEnterpriseServerNumber } = require('./patterns')
module.exports = function removeDeprecatedFrontmatter (file, frontmatterVersions, versionToDeprecate, nextOldestVersion) {
// skip files with no versions or Enterprise Server versions frontmatter
if (!frontmatterVersions) return
if (!frontmatterVersions['enterprise-server']) return
const enterpriseRange = frontmatterVersions['enterprise-server']
// skip files with versions frontmatter that applies to all enterprise-server releases
if (enterpriseRange === '*') return
// get the release numbers alone
const releaseToDeprecate = versionToDeprecate.match(getEnterpriseServerNumber)[1]
const nextOldestRelease = nextOldestVersion.match(getEnterpriseServerNumber)[1]
// if the release to deprecate is 2.13, and the FM is either '>=2.13' or '>=2.14',
// we can safely change the FM to enterprise-server: '*'
if (enterpriseRange === `>=${releaseToDeprecate}` || enterpriseRange === `>=${nextOldestRelease}`) {
frontmatterVersions['enterprise-server'] = '*'
}
}