Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
locales.map(locale => {
// If the default locale, overwrite the origin file
let localeMap =
locale === defaultLocale
? // Create a clone so we can use only current valid messages below
{ ...oldLocaleMaps[locale], ...newLocaleMaps[locale] }
: { ...newLocaleMaps[locale], ...oldLocaleMaps[locale] }
// Only keep existing keys
localeMap = pick(localeMap, Object.keys(newLocaleMaps[locale]))
const fomattedLocaleMap: object = flat
? sortKeys(localeMap, { deep: true })
: unflatten(sortKeys(localeMap), { object: true })
const fn = isJson(format) ? writeJson : writeYaml
return fn(path.resolve(buildDir, locale), fomattedLocaleMap)
})
)
locales.map(locale => {
// If the default locale, overwrite the origin file
let localeMap =
locale === defaultLocale
? // Create a clone so we can use only current valid messages below
{ ...oldLocaleMaps[locale], ...newLocaleMaps[locale] }
: { ...newLocaleMaps[locale], ...oldLocaleMaps[locale] }
// Only keep existing keys
localeMap = pick(localeMap, Object.keys(newLocaleMaps[locale]))
const fomattedLocaleMap: object = flat
? sortKeys(localeMap, { deep: true })
: unflatten(sortKeys(localeMap), { object: true })
const fn = isJson(format) ? writeJson : writeYaml
return fn(path.resolve(buildDir, locale), fomattedLocaleMap)
})
)
const same = (t, a, b) => t.same(sortKeys(a), sortKeys(b));