import * as dotenv from 'dotenv'

export function loadEnv(mode) {
  const ret = {}
  // 在应用之前咱们先指定加载哪个环境变量
  dotenv.config({
    path: `.env.${mode}`
  })

  Object.keys(process.env).forEach(envName => {
    const realName = process.env[envName].replace(/\\n/g, '\n')
    ret[envName] = realName
    process.env[envName] = realName
  })
  return ret
}
