MCPcopy Index your code
hub / github.com/formatjs/formatjs / verify

Function verify

packages/cli-lib/verify/index.ts:20–61  ·  view source on GitHub ↗
(
  files: string[],
  {sourceLocale, missingKeys, extraKeys, structuralEquality}: VerifyOpts
)

Source from the content-addressed store, hash-verified

18}
19
20export async function verify(
21 files: string[],
22 {sourceLocale, missingKeys, extraKeys, structuralEquality}: VerifyOpts
23): Promise<void> {
24 debug('Checking translation files:')
25 files.forEach(fn => debug(fn))
26
27 const translationFilesContents = (
28 await Promise.all(
29 files.map(async fn => [basename(fn, '.json'), await readJSON(fn)])
30 )
31 ).reduce<Record<string, object>>((all, [locale, content]) => {
32 all[locale] = content
33 return all
34 }, {})
35 debug('Verifying files:', files)
36
37 let exitCode = 0
38
39 if (
40 missingKeys &&
41 !(await checkMissingKeys(translationFilesContents, sourceLocale))
42 ) {
43 exitCode = 1
44 }
45
46 if (
47 extraKeys &&
48 !(await checkExtraKeys(translationFilesContents, sourceLocale))
49 ) {
50 exitCode = 1
51 }
52
53 if (
54 structuralEquality &&
55 !(await checkStructuralEquality(translationFilesContents, sourceLocale))
56 ) {
57 exitCode = 1
58 }
59
60 process.exit(exitCode)
61}

Callers 1

mainFunction · 0.85

Calls 4

checkMissingKeysFunction · 0.85
checkExtraKeysFunction · 0.85
checkStructuralEqualityFunction · 0.85
debugFunction · 0.50

Tested by

no test coverage detected