1
0
mirror of synced 2025-12-22 03:16:52 -05:00
Files
docs/middleware/contextualizers/short-versions.js
Sarah Schneider b7f48ea2c1 Support GHAE internal-only semantic versioning (#29178)
Co-authored-by: Peter Bengtsson <mail@peterbe.com>
Co-authored-by: Matt Pollard <mattpollard@users.noreply.github.com>
2022-09-22 08:26:58 +02:00

24 lines
788 B
JavaScript

// This module creates shortcuts for version comparisons in Liquid conditional strings.
//
// Supported:
// {% if fpt %}
// {% if ghae %}
// {% if ghes %}
//
// For the custom operator handling in statements like {% if ghes > 3.0 %}, see `lib/liquid-tags/if-ver.js`.
export default function shortVersions(req, res, next) {
const { allVersions, currentVersion } = req.context
const currentVersionObj = allVersions[currentVersion]
if (!currentVersionObj) return next()
// Add the short name to context.
req.context[currentVersionObj.shortName] = true
// Add convenience props.
req.context.currentVersionObj = currentVersionObj
req.context.currentRelease = currentVersion.split('@')[1]
req.context.currentVersionShortName = currentVersionObj.shortName
return next()
}