(currentVersion)
| 20 | |
| 21 | const cache = new Map() |
| 22 | function getFeaturesByVersion(currentVersion) { |
| 23 | if (!cache.has(currentVersion)) { |
| 24 | if (!allFeatures) { |
| 25 | // As of Oct 2022, the `data/features/**` reading is *not* JIT. |
| 26 | // The `data/features` is deliberately not ignored in nodemon.json. |
| 27 | // See internal issue #2389 |
| 28 | allFeatures = getDeepDataByLanguage('features', 'en') |
| 29 | } |
| 30 | |
| 31 | const features = {} |
| 32 | // Determine whether the currentVersion belongs to the list of versions the feature is available in. |
| 33 | for (const [featureName, feature] of Object.entries(allFeatures)) { |
| 34 | const { versions } = feature |
| 35 | const applicableVersions = getApplicableVersions( |
| 36 | versions, |
| 37 | path.join(ROOT, `data/features/${featureName}.yml`) |
| 38 | ) |
| 39 | |
| 40 | // Adding the resulting boolean to the context object gives us the ability to use |
| 41 | // `{% if featureName ... %}` conditionals in content files. |
| 42 | const isFeatureAvailableInCurrentVersion = applicableVersions.includes(currentVersion) |
| 43 | features[featureName] = isFeatureAvailableInCurrentVersion |
| 44 | } |
| 45 | cache.set(currentVersion, features) |
| 46 | } |
| 47 | |
| 48 | return cache.get(currentVersion) |
| 49 | } |
no test coverage detected