forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
22 lines (17 loc) · 891 Bytes
/
index.js
File metadata and controls
22 lines (17 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import path from 'path'
import { readCompressedJsonFileFallback } from '../../../lib/read-json-file.js'
import { getOpenApiVersion } from '../../../lib/all-versions.js'
export const ENABLED_APPS_DIR = 'src/github-apps/data'
export const ENABLED_APPS_FILENAME = 'server-to-server-rest.json'
const enabledForApps = new Map()
export async function getEnabledForApps(docsVersion, apiVersion) {
const openApiVersion = getOpenApiVersion(docsVersion) + (apiVersion ? `-${apiVersion}` : '')
if (!enabledForApps.has(openApiVersion)) {
// The `readCompressedJsonFileFallback()` function
// will check for both a .br and .json extension.
const appDataPath = path.join(ENABLED_APPS_DIR, openApiVersion, ENABLED_APPS_FILENAME)
const data = readCompressedJsonFileFallback(appDataPath)
enabledForApps.set(openApiVersion, data)
}
return enabledForApps.get(openApiVersion)
}