import { readFile , existsSync } from 'fs' ; export const getValueFromEnv = ( key ) : Promise < string > => new Promise ( ( resolve , reject ) => { if ( ! existsSync ( '.env' ) ) { resolve ( ) ; return ; } readFile ( '.env' , { encoding : 'utf-8' } , ( err , data ) => { if ( err ) { reject ( err ) ; return ; } const values = data . trim ( ) . split ( '\n' ) . map ( line => line . split ( /=(.*)/ ) ) . reduce < Record < string , string > > ( ( accumulation , [ key , value ] ) => ( { ... accumulation , [ key ] : value , } ) , { } ) ; resolve ( values [ key ] ) ; } ) ; } ) ;