@karmaniverous/get-dotenv 3.0.0 → 3.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 +1 -0
- package/dist/default/lib/getCli.js +4 -3
- package/dist/default/lib/getDotenv.js +11 -6
- package/lib/getCli.js +6 -7
- package/lib/getDotenv.js +9 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -272,6 +272,7 @@ get-dotenv options type
|
|
|
272
272
|
| [outputPath] | <code>string</code> | if populated, writes consolidated .env file to this path (follows [dotenv-expand rules](https://github.com/motdotla/dotenv-expand/blob/master/tests/.env)) |
|
|
273
273
|
| [paths] | <code>Array.<string></code> | array of input directory paths |
|
|
274
274
|
| [privateToken] | <code>string</code> | token indicating private variables |
|
|
275
|
+
| [vars] | <code>object</code> | explicit variables to include |
|
|
275
276
|
|
|
276
277
|
|
|
277
278
|
---
|
|
@@ -139,14 +139,14 @@ const getCli = function () {
|
|
|
139
139
|
paths,
|
|
140
140
|
pathsDelimiter,
|
|
141
141
|
suppressDotenv,
|
|
142
|
-
vars,
|
|
142
|
+
vars: varsStr,
|
|
143
143
|
varsDelimiter,
|
|
144
144
|
varsAssignor,
|
|
145
145
|
...rest
|
|
146
146
|
} = options;
|
|
147
147
|
|
|
148
148
|
// Parse vars.
|
|
149
|
-
|
|
149
|
+
const vars = varsStr !== null && varsStr !== void 0 && varsStr.length ? (0, _lodash.default)(varsStr.split(new RegExp(varsDelimiter)).map(v => v.split(new RegExp(varsAssignor)))) : undefined;
|
|
150
150
|
|
|
151
151
|
// Execute getdotenv.
|
|
152
152
|
if ((_paths = paths) !== null && _paths !== void 0 && _paths.length && !suppressDotenv) {
|
|
@@ -155,7 +155,8 @@ const getCli = function () {
|
|
|
155
155
|
var dotenv = await (0, _getDotenv.getDotenv)({
|
|
156
156
|
...rest,
|
|
157
157
|
loadProcess: true,
|
|
158
|
-
paths
|
|
158
|
+
paths,
|
|
159
|
+
vars
|
|
159
160
|
});
|
|
160
161
|
}
|
|
161
162
|
|
|
@@ -34,6 +34,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
34
34
|
* @property {string} [outputPath] - if populated, writes consolidated .env file to this path (follows {@link https://github.com/motdotla/dotenv-expand/blob/master/tests/.env dotenv-expand rules})
|
|
35
35
|
* @property {string[]} [paths] - array of input directory paths
|
|
36
36
|
* @property {string} [privateToken] - token indicating private variables
|
|
37
|
+
* @property {object} [vars] - explicit variables to include
|
|
37
38
|
*/
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -63,14 +64,15 @@ const getDotenv = async function () {
|
|
|
63
64
|
logger,
|
|
64
65
|
outputPath,
|
|
65
66
|
paths,
|
|
66
|
-
privateToken
|
|
67
|
+
privateToken,
|
|
68
|
+
vars = {}
|
|
67
69
|
} = {
|
|
68
70
|
..._dotenvDefaults.dotenvDefaults,
|
|
69
71
|
...options
|
|
70
72
|
};
|
|
71
73
|
|
|
72
74
|
// Read .env files.
|
|
73
|
-
const
|
|
75
|
+
const loaded = await paths.reduce(async (e, p) => {
|
|
74
76
|
let publicGlobal = excludePublic || excludeGlobal ? {} : (0, _readDotenv.readDotenv)(_path.default.resolve(p, dotenvToken));
|
|
75
77
|
let publicEnv = excludePublic || excludeEnv ? {} : (0, _readDotenv.readDotenv)(_path.default.resolve(p, `${dotenvToken}.${env}`));
|
|
76
78
|
let privateGlobal = excludePrivate || excludeGlobal ? {} : (0, _readDotenv.readDotenv)(_path.default.resolve(p, `${dotenvToken}.${privateToken}`));
|
|
@@ -90,7 +92,8 @@ const getDotenv = async function () {
|
|
|
90
92
|
} = (0, _dotenvExpand.expand)({
|
|
91
93
|
ignoreProcessEnv: true,
|
|
92
94
|
parsed: {
|
|
93
|
-
...
|
|
95
|
+
...loaded,
|
|
96
|
+
...vars,
|
|
94
97
|
...(outputPath ? {
|
|
95
98
|
[outputKey]: outputPath
|
|
96
99
|
} : {})
|
|
@@ -169,14 +172,15 @@ const getDotenvSync = function () {
|
|
|
169
172
|
log,
|
|
170
173
|
outputPath,
|
|
171
174
|
paths,
|
|
172
|
-
privateToken
|
|
175
|
+
privateToken,
|
|
176
|
+
vars
|
|
173
177
|
} = {
|
|
174
178
|
..._dotenvDefaults.dotenvDefaults,
|
|
175
179
|
...options
|
|
176
180
|
};
|
|
177
181
|
|
|
178
182
|
// Read .env files.
|
|
179
|
-
const
|
|
183
|
+
const loaded = paths.reduce((e, p) => {
|
|
180
184
|
let publicGlobal = excludePublic || excludeGlobal ? {} : (0, _readDotenv.readDotenvSync)(_path.default.resolve(p, dotenvToken));
|
|
181
185
|
let publicEnv = excludePublic || excludeEnv ? {} : (0, _readDotenv.readDotenvSync)(_path.default.resolve(p, `${dotenvToken}.${env}`));
|
|
182
186
|
let privateGlobal = excludePrivate || excludeGlobal ? {} : (0, _readDotenv.readDotenvSync)(_path.default.resolve(p, `${dotenvToken}.${privateToken}`));
|
|
@@ -195,7 +199,8 @@ const getDotenvSync = function () {
|
|
|
195
199
|
} = (0, _dotenvExpand.expand)({
|
|
196
200
|
ignoreProcessEnv: true,
|
|
197
201
|
parsed: {
|
|
198
|
-
...
|
|
202
|
+
...loaded,
|
|
203
|
+
...vars,
|
|
199
204
|
...(outputPath ? {
|
|
200
205
|
[outputKey]: outputPath
|
|
201
206
|
} : {})
|
package/lib/getCli.js
CHANGED
|
@@ -241,22 +241,20 @@ export const getCli = ({ defaultOptions = {}, preHook, postHook } = {}) => {
|
|
|
241
241
|
paths,
|
|
242
242
|
pathsDelimiter,
|
|
243
243
|
suppressDotenv,
|
|
244
|
-
vars,
|
|
244
|
+
vars: varsStr,
|
|
245
245
|
varsDelimiter,
|
|
246
246
|
varsAssignor,
|
|
247
247
|
...rest
|
|
248
248
|
} = options;
|
|
249
249
|
|
|
250
250
|
// Parse vars.
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
fromPairs(
|
|
255
|
-
vars
|
|
251
|
+
const vars = varsStr?.length
|
|
252
|
+
? fromPairs(
|
|
253
|
+
varsStr
|
|
256
254
|
.split(new RegExp(varsDelimiter))
|
|
257
255
|
.map((v) => v.split(new RegExp(varsAssignor)))
|
|
258
256
|
)
|
|
259
|
-
|
|
257
|
+
: undefined;
|
|
260
258
|
|
|
261
259
|
// Execute getdotenv.
|
|
262
260
|
if (paths?.length && !suppressDotenv) {
|
|
@@ -266,6 +264,7 @@ export const getCli = ({ defaultOptions = {}, preHook, postHook } = {}) => {
|
|
|
266
264
|
...rest,
|
|
267
265
|
loadProcess: true,
|
|
268
266
|
paths,
|
|
267
|
+
vars,
|
|
269
268
|
});
|
|
270
269
|
}
|
|
271
270
|
|
package/lib/getDotenv.js
CHANGED
|
@@ -27,6 +27,7 @@ import { readDotenv, readDotenvSync } from './readDotenv.js';
|
|
|
27
27
|
* @property {string} [outputPath] - if populated, writes consolidated .env file to this path (follows {@link https://github.com/motdotla/dotenv-expand/blob/master/tests/.env dotenv-expand rules})
|
|
28
28
|
* @property {string[]} [paths] - array of input directory paths
|
|
29
29
|
* @property {string} [privateToken] - token indicating private variables
|
|
30
|
+
* @property {object} [vars] - explicit variables to include
|
|
30
31
|
*/
|
|
31
32
|
|
|
32
33
|
/**
|
|
@@ -56,10 +57,11 @@ export const getDotenv = async (options = {}) => {
|
|
|
56
57
|
outputPath,
|
|
57
58
|
paths,
|
|
58
59
|
privateToken,
|
|
60
|
+
vars = {},
|
|
59
61
|
} = { ...dotenvDefaults, ...options };
|
|
60
62
|
|
|
61
63
|
// Read .env files.
|
|
62
|
-
const
|
|
64
|
+
const loaded = await paths.reduce(async (e, p) => {
|
|
63
65
|
let publicGlobal =
|
|
64
66
|
excludePublic || excludeGlobal
|
|
65
67
|
? {}
|
|
@@ -94,7 +96,8 @@ export const getDotenv = async (options = {}) => {
|
|
|
94
96
|
const { parsed: dotenv } = expand({
|
|
95
97
|
ignoreProcessEnv: true,
|
|
96
98
|
parsed: {
|
|
97
|
-
...
|
|
99
|
+
...loaded,
|
|
100
|
+
...vars,
|
|
98
101
|
...(outputPath ? { [outputKey]: outputPath } : {}),
|
|
99
102
|
},
|
|
100
103
|
});
|
|
@@ -182,10 +185,11 @@ export const getDotenvSync = (options = {}) => {
|
|
|
182
185
|
outputPath,
|
|
183
186
|
paths,
|
|
184
187
|
privateToken,
|
|
188
|
+
vars,
|
|
185
189
|
} = { ...dotenvDefaults, ...options };
|
|
186
190
|
|
|
187
191
|
// Read .env files.
|
|
188
|
-
const
|
|
192
|
+
const loaded = paths.reduce((e, p) => {
|
|
189
193
|
let publicGlobal =
|
|
190
194
|
excludePublic || excludeGlobal
|
|
191
195
|
? {}
|
|
@@ -218,7 +222,8 @@ export const getDotenvSync = (options = {}) => {
|
|
|
218
222
|
const { parsed: dotenv } = expand({
|
|
219
223
|
ignoreProcessEnv: true,
|
|
220
224
|
parsed: {
|
|
221
|
-
...
|
|
225
|
+
...loaded,
|
|
226
|
+
...vars,
|
|
222
227
|
...(outputPath ? { [outputKey]: outputPath } : {}),
|
|
223
228
|
},
|
|
224
229
|
});
|