Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,14 @@ function parse (args, opts) {

// order of precedence:
// 1. command line arg
// 2. value from config file
// 3. value from config objects
// 4. value from env var
// 2. value from env var
// 3. value from config file
// 4. value from config objects
// 5. configured default value
applyEnvVars(argv, true) // special case: check env vars that point to config file
applyEnvVars(argv, false)
setConfig(argv)
setConfigObjects()
applyEnvVars(argv, false)
applyDefaultsAndAliases(argv, flags.aliases, defaults)
applyCoercions(argv)

Expand Down
4 changes: 2 additions & 2 deletions test/yargs-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ describe('yargs-parser', function () {
})

var jsonPath = path.resolve(__dirname, './fixtures/config.json')
it('should prefer config file value over env var', function () {
it('should prefer environment variables over config file', function () {
process.env.CFG_HERP = 'zerp'
var result = parser(['--cfg', jsonPath], {
envPrefix: 'CFG',
Expand All @@ -1708,7 +1708,7 @@ describe('yargs-parser', function () {
}
})

result.herp.should.equal('derp')
result.herp.should.equal('zerp')
})

it('should support an env var value as config file option', function () {
Expand Down