MCPcopy Create free account
hub / github.com/github/docs / main

Function main

script/search/sync-search-indices.js:45–122  ·  view source on GitHub ↗
(opts, args)

Source from the content-addressed store, hash-verified

43main(program.opts(), program.args)
44
45async function main(opts, args) {
46 let language
47 if ('language' in opts) {
48 language = opts.language
49 if (process.env.LANGUAGE) {
50 console.warn(
51 `'language' specified as argument ('${language}') AND environment variable ('${process.env.LANGUAGE}')`
52 )
53 }
54 } else {
55 if (process.env.LANGUAGE && process.env.LANGUAGE !== 'all') {
56 language = process.env.LANGUAGE
57 if (!languageKeys.includes(language)) {
58 throw new Error(
59 `Environment variable 'VERSION' (${language}) is not recognized. Must be one of ${languageKeys}`
60 )
61 }
62 }
63 }
64 const notLanguage = opts.notLanguage
65 if (notLanguage && language) {
66 throw new Error("Can't specify --language *and* --not-language")
67 }
68
69 let version
70 if ('version' in opts) {
71 version = opts.version
72 if (process.env.VERSION) {
73 console.warn(
74 `'version' specified as argument ('${version}') AND environment variable ('${process.env.VERSION}')`
75 )
76 }
77 } else {
78 if (process.env.VERSION && process.env.VERSION !== 'all') {
79 version = process.env.VERSION
80 if (!allVersionKeys.includes(version)) {
81 throw new Error(
82 `Environment variable 'VERSION' (${version}) is not recognized. Must be one of ${allVersionKeys}`
83 )
84 }
85 }
86 }
87
88 // A `--version` or `process.env.VERSION` was specified, we need to convert
89 // it to the long name. I.e. `free-pro-team@latest`. Not `dotcom`.
90 // But it could also have beeb specified as `all` which means that `version`
91 // here ill be `undefined` which is also OK.
92 // const indexVersion = shortNames[version].hasNumberedReleases
93 // ? shortNames[version].currentRelease
94 // : shortNames[version].miscBaseName
95
96 let indexVersion
97 if (version && version !== 'all') {
98 // If it has been specified, it needs to be in the "long-form".
99 // I.e. `enterprise-server@3.5` not `ghes-3.5`.
100 indexVersion = version in shortNames ? shortNames[version].version : version
101 }
102 assert(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected