Skip to content

Commit

Permalink
chore: Simplify the loadFile method
Browse files Browse the repository at this point in the history
  • Loading branch information
marcbachmann committed May 11, 2019
1 parent c1ff2cf commit 1eeda6c
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ module.exports = class Conf {
assert(path.isAbsolute(configDir), 'configDir must be an absolute path')
const conf = new Conf()

conf.merge(loadFile(configDir, 'environments/', 'all', {required: true}))
conf.merge(loadFile(configDir, 'environments', env, {required: true}))
conf.merge(loadFile(configDir, 'secrets', env, {required: false}))
conf.merge(loadFile([configDir, 'environments/all'], {required: true}))
conf.merge(loadFile([configDir, 'environments', env], {required: true}))
conf.merge(loadFile([configDir, 'secrets', env], {required: false}))
conf.merge(getEnvVariables())
conf.set('environment', env)
return conf
Expand Down Expand Up @@ -47,10 +47,7 @@ module.exports = class Conf {
}
}

function loadFile () {
const parts = _.take(arguments, arguments.length - 1)
const opts = arguments[arguments.length - 1]
const required = opts.required
function loadFile (parts, opts) {
const p = path.join.apply(path, parts)

try {
Expand Down

0 comments on commit 1eeda6c

Please sign in to comment.