const path = require ( 'path' ) ; const fs = require ( 'fs' ) ; const { promisify } = require ( 'util' ) ; const exists = promisify ( fs . exists ) ; const readDir = promisify ( fs . readdir ) ; module . exports = listLocales ; const ignorePattern = /^_|\./ ; async function listLocales ( ) { const localesPath = path . resolve ( process . cwd ( ) , 'src/locale' ) ; const locales = await readDir ( localesPath ) ; return Promise . all ( locales . filter ( ( file ) => ! ignorePattern . test ( file ) ) . map ( async ( locale ) => { const isTs = await exists ( path . join ( localesPath , locale , 'index.ts' ) ) ; return { name : locale . replace ( /-/g , '' ) , code : locale , path : `./${ locale }` , fullPath : `./src/locale/${ locale }/index.${ isTs ? 'ts' : 'js' }` , } ; } ) ) ; }