import chalk from 'chalk' ; import { createFailError } from '@kbn/dev-utils' ; import { ErrorReporter , extractMessagesFromPathToMap , filterConfigPaths , I18nConfig } from '..' ; export function extractDefaultMessages ( config , inputPaths ) { const filteredPaths = filterConfigPaths ( inputPaths , config ) as string [ ] ; if ( filteredPaths . length === 0 ) { throw createFailError ( `${ chalk . white . bgRed ( ' I18N ERROR ' ) } None of input paths is covered by the mappings in .i18nrc.json.` ) ; } return filteredPaths . map ( ( filteredPath ) => ( { task : async ( context ) => { const { messages , reporter } = context ; const initialErrorsNumber = reporter . errors . length ; const result = await extractMessagesFromPathToMap ( filteredPath , messages , config , reporter ) ; if ( reporter . errors . length === initialErrorsNumber ) { return result ; } throw reporter ; } , title : filteredPath , } ) ) ; }