import fs = require('fs')
import defaultConfig from './config.default'

const { ENV, isInTsNode } = defaultConfig

const config = { ...defaultConfig }
if (ENV) {
  const p = `${__dirname}/config.${ENV}.${isInTsNode ? 'ts' : 'js'}`
  if (fs.existsSync(p)) {
    const { default: envConfig } = require(p)
    Object.assign(config, envConfig)
  }
}

export default config
