The README says
The env resolution pattern follows the one used by Rail's dotenv and create-react-app
But the code says
|
const dotenvFiles = [ |
|
`.env.${env}.local`, |
|
`.env.${env}`, |
|
// Don't include `.env.local` for `test` environment |
|
// since normally you expect tests to produce the same |
|
// results for everyone |
|
env !== 'test' && `.env.local`, |
|
`.env`, |
|
] |
and
|
const envVarsArray = envFileNames.map((fileName) => { |
|
const parsed = dotenv.config({ path: fileName }) |
|
return this.variableExpansion |
|
? dotenvExpand(parsed).parsed |
|
: parsed.parsed |
|
}) |
|
|
|
return envVarsArray.reduce((acc, curr) => ({ ...acc, ...curr }), {}) |
That last .reduce() call means we're actually resolving the files in reverse order of precedence, since env vars in lower priority files are overwriting the ones in higher priority files.
The fix is potentially a breaking change, and so requires a major version bump.
The README says
But the code says
serverless-dotenv-plugin/index.js
Lines 64 to 72 in 6fc076c
serverless-dotenv-plugin/index.js
Lines 84 to 91 in 6fc076c
That last
.reduce()call means we're actually resolving the files in reverse order of precedence, since env vars in lower priority files are overwriting the ones in higher priority files.The fix is potentially a breaking change, and so requires a major version bump.