import { resolve , join } from 'path' ; import { ErrorReporter , I18nConfig , assignConfigFromPath , arrayify } from '..' ; export function mergeConfigs ( additionalConfigPaths = [ ] ) { const root = join ( __dirname , '../../../../' ) ; const kibanaRC = resolve ( root , '.i18nrc.json' ) ; const xpackRC = resolve ( root , 'x-pack/.i18nrc.json' ) ; const configPaths = [ kibanaRC , xpackRC , ... arrayify ( additionalConfigPaths ) ] ; return configPaths . map ( ( configPath ) => ( { task : async ( context ) => { try { context . config = await assignConfigFromPath ( context . config , configPath ) ; } catch ( err ) { const { reporter } = context ; const reporterWithContext = reporter . withContext ( { name : configPath } ) ; reporterWithContext . report ( err ) ; throw reporter ; } } , title : `Merging configs in ${ configPath }` , } ) ) ; }