forked from sebastian-software/universal-dotenv
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial release of lazy-universal-dotenv
- Loading branch information
Showing
15 changed files
with
118 additions
and
174 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
EXPAND_PATH = /usr/bin:$BINARY_PATH |
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 @@ | ||
BINARY_PATH = /usr/local/bin |
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 @@ | ||
EXPAND_DATA=red,$APP_DATA |
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,2 +0,0 @@ | ||
extends: | ||
- readable | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,39 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Supports expand of variable from .env 1`] = ` | ||
Object { | ||
"APP_TEST_OVERRIDE": "original", | ||
"APP_TEST_PATH": "one/two/three.js", | ||
"BINARY_PATH": "/usr/local/bin", | ||
"EXPAND_PATH": "/usr/bin:/usr/local/bin", | ||
"TEST_IGNORE": "123", | ||
} | ||
`; | ||
|
||
exports[`Supports expand of variable from .env 2`] = ` | ||
Object { | ||
"APP_TEST_OVERRIDE": "\\"original\\"", | ||
"APP_TEST_PATH": "\\"one/two/three.js\\"", | ||
"BINARY_PATH": "\\"/usr/local/bin\\"", | ||
"EXPAND_PATH": "\\"/usr/bin:/usr/local/bin\\"", | ||
"TEST_IGNORE": "\\"123\\"", | ||
} | ||
`; | ||
|
||
exports[`Supports expand of variable from environment 1`] = ` | ||
Object { | ||
"APP_TEST_OVERRIDE": "original", | ||
"APP_TEST_PATH": "one/two/three.js", | ||
"EXPAND_DATA": "red,yellow", | ||
"TEST_IGNORE": "123", | ||
} | ||
`; | ||
|
||
exports[`Supports expand of variable from environment 2`] = ` | ||
Object { | ||
"APP_TEST_OVERRIDE": "\\"original\\"", | ||
"APP_TEST_PATH": "\\"one/two/three.js\\"", | ||
"EXPAND_DATA": "\\"red,yellow\\"", | ||
"TEST_IGNORE": "\\"123\\"", | ||
} | ||
`; |
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,43 +1,17 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Ignores non app-specific settings 1`] = ` | ||
exports[`Doesn't support manually defined envs 1`] = ` | ||
Object { | ||
"APP_ROOT": Any<String>, | ||
"APP_SOURCE": Any<String>, | ||
"APP_TEST_OVERRIDE": "overridden", | ||
"APP_TEST_PATH": "one/two/three.js", | ||
"NODE_ENV": "test", | ||
"TEST_IGNORE": "123", | ||
} | ||
`; | ||
|
||
exports[`Ignores non app-specific settings 2`] = ` | ||
exports[`Doesn't support manually defined envs 2`] = ` | ||
Object { | ||
"APP_ROOT": Any<String>, | ||
"APP_SOURCE": Any<String>, | ||
"APP_TEST_OVERRIDE": "\\"overridden\\"", | ||
"APP_TEST_PATH": "\\"one/two/three.js\\"", | ||
"NODE_ENV": "\\"test\\"", | ||
} | ||
`; | ||
exports[`Supports manually defined envs 1`] = ` | ||
Object { | ||
"APP_DATA": "yellow", | ||
"APP_ROOT": Any<String>, | ||
"APP_SOURCE": Any<String>, | ||
"APP_TEST_OVERRIDE": "overridden", | ||
"APP_TEST_PATH": "one/two/three.js", | ||
"NODE_ENV": "test", | ||
} | ||
`; | ||
exports[`Supports manually defined envs 2`] = ` | ||
Object { | ||
"APP_DATA": "\\"yellow\\"", | ||
"APP_ROOT": Any<String>, | ||
"APP_SOURCE": Any<String>, | ||
"APP_TEST_OVERRIDE": "\\"overridden\\"", | ||
"APP_TEST_PATH": "\\"one/two/three.js\\"", | ||
"NODE_ENV": "\\"test\\"", | ||
"TEST_IGNORE": "\\"123\\"", | ||
} | ||
`; |
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,19 @@ | ||
import { getEnvironment } from "." | ||
|
||
const snapshotOpts = {} | ||
|
||
test("Supports expand of variable from .env", () => { | ||
const { raw, stringified, webpack } = getEnvironment({ nodeEnv: 'expansion1' }) | ||
expect(raw).toMatchSnapshot(snapshotOpts) | ||
expect(stringified).toMatchSnapshot(snapshotOpts) | ||
expect(webpack).toBeDefined() | ||
}) | ||
|
||
test("Supports expand of variable from environment", () => { | ||
process.env.APP_DATA = "yellow" | ||
const { raw, stringified, webpack } = getEnvironment({ nodeEnv: 'expansion2' }) | ||
expect(raw).toMatchSnapshot(snapshotOpts) | ||
expect(stringified).toMatchSnapshot(snapshotOpts) | ||
expect(webpack).toBeDefined() | ||
delete process.env.APP_DATA | ||
}) |
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,50 +1,12 @@ | ||
import { getEnvironment } from "." | ||
|
||
const snapshotOpts = { | ||
APP_ROOT: expect.any(String), | ||
APP_SOURCE: expect.any(String) | ||
} | ||
const snapshotOpts = {} | ||
|
||
test("Sets up process.env", () => { | ||
expect(process.env.APP_TEST_PATH).toBe("one/two/three.js") | ||
expect(process.env.TEST_IGNORE).toBe("123") | ||
}) | ||
|
||
test("Ignores non app-specific settings", () => { | ||
const { raw, stringified, webpack } = getEnvironment() | ||
expect(raw).toMatchSnapshot(snapshotOpts) | ||
expect(stringified).toMatchSnapshot(snapshotOpts) | ||
expect(webpack).toBeDefined() | ||
}) | ||
|
||
test("Supports manually defined envs", () => { | ||
test("Doesn't support manually defined envs", () => { | ||
process.env.APP_DATA = "yellow" | ||
const { raw, stringified, webpack } = getEnvironment() | ||
expect(raw).toMatchSnapshot(snapshotOpts) | ||
expect(stringified).toMatchSnapshot(snapshotOpts) | ||
expect(webpack).toBeDefined() | ||
delete process.env.APP_DATA | ||
}) | ||
|
||
test("Exports NODE_ENV", () => { | ||
const { raw } = getEnvironment() | ||
expect(raw.NODE_ENV).toBe("test") | ||
}) | ||
|
||
test("Exports APP_ROOT", () => { | ||
const { raw } = getEnvironment() | ||
expect(raw.APP_ROOT).toMatch(/universal-dotenv$/) | ||
}) | ||
|
||
test("Exports APP_SOURCE", () => { | ||
const { raw } = getEnvironment() | ||
expect(raw.APP_SOURCE).toMatch(/universal-dotenv[\\/]src$/) | ||
}) | ||
|
||
test("Adds APP_ROOT to process.env", () => { | ||
expect(process.env.APP_ROOT).toBeDefined() | ||
}) | ||
|
||
test("Adds APP_SOURCE to process.env", () => { | ||
expect(process.env.APP_SOURCE).toBeDefined() | ||
}) |
Oops, something went wrong.