-
-
Notifications
You must be signed in to change notification settings - Fork 861
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from Glavin001/patch-1
Close #115. Add example code for overriding process.env to FAQ
- Loading branch information
Showing
1 changed file
with
12 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,6 +155,18 @@ No. We **strongly** recommend against having a "main" `.env` file and an "enviro | |
|
||
We will never modify any environment variables that have already been set. In particular, if there is a variable in your `.env` file which collides with one that already exists in your environment, then that variable will be skipped. This behavior allows you to override all `.env` configurations with a machine-specific environment, although it is not recommended. | ||
|
||
If you want to override `process.env` you can do something like this: | ||
|
||
```javascript | ||
const fs = require('fs') | ||
const dotenv = require('dotenv') | ||
const envConfig = dotenv.parse(fs.readFileSync('.env.override')) | ||
for (var k in envConfig) { | ||
process.env[k] = envConfig[k] | ||
} | ||
``` | ||
|
||
|
||
### Can I customize/write plugins for dotenv? | ||
|
||
For `[email protected]`: Yes. `dotenv.config()` now returns an object representing | ||
|