| 119 | } |
| 120 | |
| 121 | function makeLiquidReplacements(replacementsObj, text) { |
| 122 | let newText = text |
| 123 | Object.entries(replacementsObj).forEach(([oldCond, newCond]) => { |
| 124 | const oldCondRegex = new RegExp(`({%-?)\\s*?${escapeRegExp(oldCond)}\\s*?(-?%})`, 'g') |
| 125 | newText = newText |
| 126 | .replace(oldCondRegex, `$1 ${newCond} $2`) |
| 127 | // Content files use an old-school hack to ensure our old regex deprecation script DTRT, for example: |
| 128 | // `if enterpriseServerVersions contains currentVersion and currentVersion ver_gt "enterprise-server@2.21"` |
| 129 | // This script will change the above to `if ghes and ghes > 2.21`. |
| 130 | // But we don't need the hack for the new deprecation script, because it will change `if ghes > 2.21` to `if ghes`. |
| 131 | // So we can update this to the simpler `{% if ghes > 2.21 %}`. |
| 132 | .replace(/ghes and ghes/g, 'ghes') |
| 133 | }) |
| 134 | |
| 135 | return newText |
| 136 | } |
| 137 | |
| 138 | // Versions map: |
| 139 | // if currentVersion == "myVersion@myRelease" -> ifversion myVersionShort OR ifversion myVersionShort = @myRelease |