diff --git a/CHANGELOG.md b/CHANGELOG.md
index bf172df5..cd060f3c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,21 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
+
+# [5.0.0](https://github.com/yargs/yargs-parser/compare/v4.2.1...v5.0.0) (2017-02-18)
+
+
+### Bug Fixes
+
+* environment variables should take precedence over config file ([#81](https://github.com/yargs/yargs-parser/issues/81)) ([76cee1f](https://github.com/yargs/yargs-parser/commit/76cee1f))
+
+
+### BREAKING CHANGES
+
+* environment variables will now override config files (args, env, config-file, config-object)
+
+
+
## [4.2.1](https://github.com/yargs/yargs-parser/compare/v4.2.0...v4.2.1) (2017-01-02)
diff --git a/README.md b/README.md
index cf451748..6d5916c3 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ The mighty option parser used by [yargs](https://github.com/yargs/yargs).
visit the [yargs website](http://yargs.js.org/) for more examples, and thorough usage instructions.
-
+
## Example
diff --git a/index.js b/index.js
index 1a04d559..b71faf58 100644
--- a/index.js
+++ b/index.js
@@ -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)
diff --git a/package.json b/package.json
index 9b3ddd55..d025a7ef 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "yargs-parser",
- "version": "4.2.1",
+ "version": "5.0.0",
"description": "the mighty option parser used by yargs",
"main": "index.js",
"scripts": {
diff --git a/test/yargs-parser.js b/test/yargs-parser.js
index c9c59993..5b59c615 100644
--- a/test/yargs-parser.js
+++ b/test/yargs-parser.js
@@ -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',
@@ -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 () {