MCPcopy
hub / github.com/formatjs/formatjs / main

Function main

tools/generate-cldr-locales.ts:73–97  ·  view source on GitHub ↗
(args: Args)

Source from the content-addressed store, hash-verified

71}
72
73function main(args: Args) {
74 const {cldrPackage, jsonPath, out, variable = 'ALL_LOCALES'} = args
75 const patterns = asArray(args.glob)
76
77 if (!cldrPackage) {
78 throw new Error('--cldrPackage is required')
79 }
80 if (!out) {
81 throw new Error('--out is required')
82 }
83 if (!patterns.length) {
84 throw new Error('--glob is required')
85 }
86
87 const packageRoot = getPackageRoot(cldrPackage)
88 const root = args.baseDir ? join(packageRoot, args.baseDir) : packageRoot
89 const files = glob.sync(patterns, {cwd: root, onlyFiles: true}).sort()
90 const locales = new Set(
91 jsonPath
92 ? getLocalesFromJson(root, files, jsonPath)
93 : getLocalesFromFiles(files)
94 )
95
96 outputFileSync(out, formatLocales(variable, [...locales].sort()))
97}
98
99if (import.meta.filename === process.argv[1]) {
100 main(minimist<Args>(process.argv.slice(2)))

Callers 1

Calls 5

asArrayFunction · 0.85
getPackageRootFunction · 0.85
getLocalesFromJsonFunction · 0.85
getLocalesFromFilesFunction · 0.85
formatLocalesFunction · 0.85

Tested by

no test coverage detected