-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dotenv): ability to have local and environment-specific dotenv f…
…iles (#162)
- Loading branch information
1 parent
90c1ef7
commit 0dcf472
Showing
22 changed files
with
145 additions
and
59 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
NODE_ENV=development | ||
WARTHOG_APP_HOST=localhost | ||
WARTHOG_APP_PORT=4100 | ||
WARTHOG_DB_DATABASE=warthog-example-1 | ||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
NODE_ENV=development | ||
WARTHOG_APP_HOST=localhost | ||
WARTHOG_APP_PORT=4100 | ||
WARTHOG_DB_DATABASE=warthog-example-2 | ||
|
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
NODE_ENV=development | ||
WARTHOG_APP_HOST=localhost | ||
WARTHOG_APP_PORT=4100 | ||
WARTHOG_DB_DATABASE=warthog-example-3 | ||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
NODE_ENV=development | ||
WARTHOG_APP_HOST=localhost | ||
WARTHOG_APP_PORT=4100 | ||
WARTHOG_DB_DATABASE=warthog-example-4 | ||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
NODE_ENV=development | ||
WARTHOG_APP_HOST=localhost | ||
WARTHOG_APP_PORT=4100 | ||
WARTHOG_DB_CONNECTION=postgres | ||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
NODE_ENV=development | ||
WARTHOG_APP_HOST=localhost | ||
WARTHOG_APP_PORT=4100 | ||
WARTHOG_DB_DATABASE=warthog-example-6 | ||
|
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
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
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
NODE_ENV=development | ||
WARTHOG_APP_HOST=localhost | ||
WARTHOG_APP_PORT=4100 | ||
WARTHOG_DB_DATABASE=warthog-example-8 | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
WARTHOG_DB_PASSWORD=SUPER_SECRET_PASSWORD | ||
WARTHOG_FOO_BAR=BAZ |
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
WARTHOG_ENV=111 | ||
WARTHOG_A=ENV | ||
WARTHOG_B=ENV | ||
WARTHOG_C=ENV | ||
WARTHOG_D=ENV | ||
|
||
# required variables | ||
WARTHOG_APP_HOST=localhost | ||
WARTHOG_APP_PORT=4100 | ||
WARTHOG_DB_DATABASE=warthog-example-1 | ||
WARTHOG_DB_USERNAME=postgres | ||
WARTHOG_DB_PASSWORD= | ||
WARTHOG_DB_SYNCHRONIZE=true | ||
WARTHOG_DB_HOST=localhost |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
WARTHOG_ENV_LOCAL=222 | ||
WARTHOG_B=ENV_LOCAL | ||
WARTHOG_C=ENV_LOCAL | ||
WARTHOG_D=ENV_LOCAL |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
WARTHOG_ENV_LOCAL_DEVELOPMENT=333 | ||
WARTHOG_C=ENV_LOCAL_DEVELOPMENT | ||
WARTHOG_D=ENV_LOCAL_DEVELOPMENT |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
WARTHOG_ENV_LOCAL_PRODUCTION=444 | ||
|
||
WARTHOG_D=ENV_LOCAL_PRODUCTION | ||
|
||
# Make sure we use the actual environment variable | ||
WARTHOG_PROPER_ENV_VARIABLE=ERROR |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Config } from '../../config'; | ||
|
||
describe('Dotenv files', () => { | ||
it('Pulls config in correct order', async () => { | ||
process.env = { | ||
NODE_ENV: 'development', | ||
WARTHOG_PROPER_ENV_VARIABLE: '12345' | ||
}; | ||
|
||
new Config({ dotenvPath: __dirname }).loadSync(); | ||
|
||
expect(process.env.WARTHOG_PROPER_ENV_VARIABLE).toEqual('12345'); | ||
expect(process.env.WARTHOG_ENV_LOCAL_DEVELOPMENT).toEqual('333'); | ||
expect(process.env.WARTHOG_C).toEqual('ENV_LOCAL_DEVELOPMENT'); | ||
expect(process.env.WARTHOG_D).toEqual('ENV_LOCAL_DEVELOPMENT'); | ||
expect(process.env.WARTHOG_ENV_LOCAL).toEqual('222'); | ||
expect(process.env.WARTHOG_B).toEqual('ENV_LOCAL'); | ||
expect(process.env.WARTHOG_ENV).toEqual('111'); | ||
expect(process.env.WARTHOG_A).toEqual('ENV'); | ||
}); | ||
}); |