import * as fse from 'fs-extra' ; import * as upath from 'upath' ; import * as DotEnv from 'dotenv' ; /**
 * Attempt to parse .env file in the folder.
 */ export async function readDotEnvFrom ( folder ) { const file = upath . join ( folder , '.env' ) ; if ( await fse . pathExists ( file ) === false ) { return { } ; } const dotEnvRaw = await fse . readFile ( file , 'utf8' ) ; return DotEnv . parse ( dotEnvRaw ) ; } export function parseCliEnvFlags ( yargsEnv ) { const env = { } ; if ( yargsEnv && typeof yargsEnv === 'object' && Array . isArray ( yargsEnv ) === false ) { for ( const key in yargsEnv ) { env [ key ] = yargsEnv [ key ] . toString ( ) ; } } return env ; }