@jdeighan/env 9.1.18 → 9.1.19
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +3 -3
- package/src/EnvLoaderEx.coffee +9 -5
- package/src/EnvLoaderEx.js +8 -4
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jdeighan/env",
|
3
3
|
"type": "module",
|
4
|
-
"version": "9.1.
|
4
|
+
"version": "9.1.19",
|
5
5
|
"description": "enhanced syntax for .env files",
|
6
6
|
"main": "./src/EnvLoaderEx.js",
|
7
7
|
"exports": {
|
@@ -31,8 +31,8 @@
|
|
31
31
|
},
|
32
32
|
"homepage": "https://github.com/johndeighan/env#readme",
|
33
33
|
"dependencies": {
|
34
|
-
"@jdeighan/coffee-utils": "^7.0.
|
35
|
-
"@jdeighan/mapper": "^
|
34
|
+
"@jdeighan/coffee-utils": "^7.0.21",
|
35
|
+
"@jdeighan/mapper": "^15.0.0",
|
36
36
|
"coffeescript": "^2.6.1",
|
37
37
|
"cross-env": "^7.0.3"
|
38
38
|
},
|
package/src/EnvLoaderEx.coffee
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
import pathlib from 'path'
|
4
4
|
|
5
5
|
import {
|
6
|
-
assert, undef, pass, error, rtrim, isArray, isFunction,
|
6
|
+
assert, undef, pass, error, rtrim, isArray, isHash, isFunction,
|
7
7
|
rtrunc, escapeStr, croak,
|
8
8
|
} from '@jdeighan/coffee-utils'
|
9
9
|
import {log} from '@jdeighan/coffee-utils/log'
|
@@ -259,10 +259,13 @@ export class EnvLoader extends TreeMapper
|
|
259
259
|
# ---------------------------------------------------------------------------
|
260
260
|
# Load environment from a string
|
261
261
|
|
262
|
-
export loadEnvString = (contents, hOptions
|
262
|
+
export loadEnvString = (contents, hOptions) ->
|
263
263
|
|
264
|
-
debug "enter loadEnvString()"
|
265
|
-
|
264
|
+
debug "enter loadEnvString()", hOptions
|
265
|
+
assert isHash(hOptions),\
|
266
|
+
"loadEnvString(): 2nd arg not a hash #{typeof hOptions}"
|
267
|
+
assert hOptions.source, "loadEnvString(): Missing source"
|
268
|
+
env = new EnvLoader(contents, hOptions.source, hOptions)
|
266
269
|
env.load()
|
267
270
|
debug "return from loadEnvString()"
|
268
271
|
return
|
@@ -274,7 +277,8 @@ export loadEnvFile = (filepath, hOptions={}) ->
|
|
274
277
|
|
275
278
|
debug "enter loadEnvFile #{filepath}"
|
276
279
|
contents = slurp filepath
|
277
|
-
|
280
|
+
hOptions.source = filepath
|
281
|
+
loadEnvString contents, hOptions
|
278
282
|
debug "return from loadEnvFile"
|
279
283
|
return
|
280
284
|
|
package/src/EnvLoaderEx.js
CHANGED
@@ -11,6 +11,7 @@ import {
|
|
11
11
|
error,
|
12
12
|
rtrim,
|
13
13
|
isArray,
|
14
|
+
isHash,
|
14
15
|
isFunction,
|
15
16
|
rtrunc,
|
16
17
|
escapeStr,
|
@@ -269,10 +270,12 @@ export var EnvLoader = class EnvLoader extends TreeMapper {
|
|
269
270
|
// ---------------------------------------------------------------------------
|
270
271
|
// ---------------------------------------------------------------------------
|
271
272
|
// Load environment from a string
|
272
|
-
export var loadEnvString = function(contents, hOptions
|
273
|
+
export var loadEnvString = function(contents, hOptions) {
|
273
274
|
var env;
|
274
|
-
debug("enter loadEnvString()");
|
275
|
-
|
275
|
+
debug("enter loadEnvString()", hOptions);
|
276
|
+
assert(isHash(hOptions), `loadEnvString(): 2nd arg not a hash ${typeof hOptions}`);
|
277
|
+
assert(hOptions.source, "loadEnvString(): Missing source");
|
278
|
+
env = new EnvLoader(contents, hOptions.source, hOptions);
|
276
279
|
env.load();
|
277
280
|
debug("return from loadEnvString()");
|
278
281
|
};
|
@@ -283,7 +286,8 @@ export var loadEnvFile = function(filepath, hOptions = {}) {
|
|
283
286
|
var contents;
|
284
287
|
debug(`enter loadEnvFile ${filepath}`);
|
285
288
|
contents = slurp(filepath);
|
286
|
-
|
289
|
+
hOptions.source = filepath;
|
290
|
+
loadEnvString(contents, hOptions);
|
287
291
|
debug("return from loadEnvFile");
|
288
292
|
};
|
289
293
|
|