dotenv-defaults 1.0.3 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -1
- package/config.js +7 -0
- package/package.json +5 -4
- package/src/index.js +1 -4
- package/src/index.test.js +5 -5
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ A dotenv system that supports defaults
|
|
|
5
5
|
### Status
|
|
6
6
|
|
|
7
7
|

|
|
8
|
-
[](https://dependabot.com/)
|
|
9
9
|
|
|
10
10
|
### Installation
|
|
11
11
|
|
|
@@ -35,6 +35,9 @@ The result
|
|
|
35
35
|
```js
|
|
36
36
|
require('dotenv-defaults').config()
|
|
37
37
|
|
|
38
|
+
// Or you can also load it directly like this
|
|
39
|
+
require('dotenv-defaults/config')
|
|
40
|
+
|
|
38
41
|
console.log(process.env.HOST)
|
|
39
42
|
// Outputs: omnionline.us
|
|
40
43
|
|
|
@@ -42,6 +45,18 @@ console.log(process.env.EMAIL)
|
|
|
42
45
|
// Outputs: test@email.com
|
|
43
46
|
```
|
|
44
47
|
|
|
48
|
+
##### TypeScript
|
|
49
|
+
Since this module does not provide TypeScript Type Definitions if you try to import it like `import dotenv from "dotenv-defaults"` TypeScript will return an error.
|
|
50
|
+
|
|
51
|
+
Instead you should load it like this:
|
|
52
|
+
```typescript
|
|
53
|
+
import "dotenv-defaults/config"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
##### CLI
|
|
57
|
+
You can also call this module directly when using the node executable.
|
|
58
|
+
So, for example if you are running a custom script with node and you want to load your environment variables you can do the following `node -r dotenv-defaults/config your-script.js`. (_When using this method, please make sure that you have installed dotenv-defaults with npm or yarn in the same directory_)
|
|
59
|
+
|
|
45
60
|
### Differences
|
|
46
61
|
|
|
47
62
|
The only thing to note is that the original module supported an `options` argument in the `config` function.
|
package/config.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// The purpose of this file is to be able to load the module with...
|
|
2
|
+
// ... "require("dotenv-defaults/config")" in JavaScript or "import "dotenv-defaults/config"" in TypeScript...
|
|
3
|
+
// ... or "node -r dotenv-defaults/config script.js" from the command line
|
|
4
|
+
|
|
5
|
+
(function () {
|
|
6
|
+
require('./src/index').config()
|
|
7
|
+
})()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dotenv-defaults",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "dotenv... but with defaults!",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,15 +26,16 @@
|
|
|
26
26
|
"url": "https://github.com/mrsteele/dotenv-defaults/issues"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
|
-
"src"
|
|
29
|
+
"src",
|
|
30
|
+
"config.js"
|
|
30
31
|
],
|
|
31
32
|
"homepage": "https://github.com/mrsteele/dotenv-defaults#readme",
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"dotenv": "^
|
|
34
|
+
"dotenv": "^8.2.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"jest": "^25.0.0",
|
|
37
|
-
"standard": "^
|
|
38
|
+
"standard": "^14.3.4"
|
|
38
39
|
},
|
|
39
40
|
"jest": {
|
|
40
41
|
"coverageDirectory": "./coverage/",
|
package/src/index.js
CHANGED
package/src/index.test.js
CHANGED
|
@@ -50,12 +50,12 @@ describe('dotenv-defaults', () => {
|
|
|
50
50
|
})
|
|
51
51
|
|
|
52
52
|
test('should read variables', () => {
|
|
53
|
-
expect(Module.parse(
|
|
53
|
+
expect(Module.parse('TEST=hello')).toEqual({ TEST: 'hello' })
|
|
54
54
|
})
|
|
55
55
|
|
|
56
56
|
test('should include defaults', () => {
|
|
57
|
-
const src =
|
|
58
|
-
const defaults =
|
|
57
|
+
const src = 'TEST=hello'
|
|
58
|
+
const defaults = 'TEST2=goodbye'
|
|
59
59
|
expect(Module.parse(src, defaults)).toEqual({
|
|
60
60
|
TEST: 'hello',
|
|
61
61
|
TEST2: 'goodbye'
|
|
@@ -63,8 +63,8 @@ describe('dotenv-defaults', () => {
|
|
|
63
63
|
})
|
|
64
64
|
|
|
65
65
|
test('should not override defaults', () => {
|
|
66
|
-
const src =
|
|
67
|
-
const defaults =
|
|
66
|
+
const src = 'TEST=hello'
|
|
67
|
+
const defaults = 'TEST=goodbye'
|
|
68
68
|
expect(Module.parse(src, defaults)).toEqual({ TEST: 'hello' })
|
|
69
69
|
})
|
|
70
70
|
})
|