@jdeighan/env 9.1.20 → 9.1.23
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/package.json +3 -3
- package/src/EnvLoaderEx.coffee +7 -4
- package/src/EnvLoaderEx.js +9 -5
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.23",
|
|
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": "^15.0.
|
|
34
|
+
"@jdeighan/coffee-utils": "^7.0.23",
|
|
35
|
+
"@jdeighan/mapper": "^15.0.4",
|
|
36
36
|
"coffeescript": "^2.6.1",
|
|
37
37
|
"cross-env": "^7.0.3"
|
|
38
38
|
},
|
package/src/EnvLoaderEx.coffee
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '@jdeighan/coffee-utils'
|
|
9
9
|
import {log} from '@jdeighan/coffee-utils/log'
|
|
10
10
|
import {debug} from '@jdeighan/coffee-utils/debug'
|
|
11
|
-
import {slurp, pathTo, mkpath} from '@jdeighan/coffee-utils/fs'
|
|
11
|
+
import {slurp, pathTo, mkpath, parseSource} from '@jdeighan/coffee-utils/fs'
|
|
12
12
|
import {TreeMapper} from '@jdeighan/mapper/tree'
|
|
13
13
|
|
|
14
14
|
hDefCallbacks = {
|
|
@@ -285,13 +285,16 @@ export loadEnvFile = (filepath, hOptions={}) ->
|
|
|
285
285
|
# ---------------------------------------------------------------------------
|
|
286
286
|
# Load environment from .env file
|
|
287
287
|
|
|
288
|
-
export loadEnvFrom = (
|
|
288
|
+
export loadEnvFrom = (source, hOptions={}) ->
|
|
289
289
|
# --- valid options:
|
|
290
290
|
# onefile - load only the first file found
|
|
291
291
|
# hCallbacks - getVar, setVar, clearVar, clearAll, names
|
|
292
292
|
|
|
293
|
-
|
|
294
|
-
|
|
293
|
+
source = mkpath(source)
|
|
294
|
+
debug "enter loadEnvFrom '#{source}'"
|
|
295
|
+
hSourceInfo = parseSource(source)
|
|
296
|
+
debug 'hSourceInfo', hSourceInfo
|
|
297
|
+
path = pathTo('.env', source, "up")
|
|
295
298
|
if ! path?
|
|
296
299
|
debug "return from loadEnvFrom() - no .env file found"
|
|
297
300
|
return
|
package/src/EnvLoaderEx.js
CHANGED
|
@@ -29,7 +29,8 @@ import {
|
|
|
29
29
|
import {
|
|
30
30
|
slurp,
|
|
31
31
|
pathTo,
|
|
32
|
-
mkpath
|
|
32
|
+
mkpath,
|
|
33
|
+
parseSource
|
|
33
34
|
} from '@jdeighan/coffee-utils/fs';
|
|
34
35
|
|
|
35
36
|
import {
|
|
@@ -293,13 +294,16 @@ export var loadEnvFile = function(filepath, hOptions = {}) {
|
|
|
293
294
|
|
|
294
295
|
// ---------------------------------------------------------------------------
|
|
295
296
|
// Load environment from .env file
|
|
296
|
-
export var loadEnvFrom = function(
|
|
297
|
-
var filepath, i, lPaths, len, path;
|
|
297
|
+
export var loadEnvFrom = function(source, hOptions = {}) {
|
|
298
|
+
var filepath, hSourceInfo, i, lPaths, len, path;
|
|
298
299
|
// --- valid options:
|
|
299
300
|
// onefile - load only the first file found
|
|
300
301
|
// hCallbacks - getVar, setVar, clearVar, clearAll, names
|
|
301
|
-
|
|
302
|
-
|
|
302
|
+
source = mkpath(source);
|
|
303
|
+
debug(`enter loadEnvFrom '${source}'`);
|
|
304
|
+
hSourceInfo = parseSource(source);
|
|
305
|
+
debug('hSourceInfo', hSourceInfo);
|
|
306
|
+
path = pathTo('.env', source, "up");
|
|
303
307
|
if (path == null) {
|
|
304
308
|
debug("return from loadEnvFrom() - no .env file found");
|
|
305
309
|
return;
|