@jdeighan/coffee-utils 7.0.32 → 7.0.33
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 +1 -1
- package/src/coffee_utils.coffee +9 -8
- package/src/coffee_utils.js +11 -8
package/package.json
CHANGED
package/src/coffee_utils.coffee
CHANGED
|
@@ -391,15 +391,16 @@ export replaceVars = (line, hVars={}, rx=/__(env\.)?([A-Za-z_]\w*)__/g) ->
|
|
|
391
391
|
|
|
392
392
|
replacerFunc = (match, prefix, name) =>
|
|
393
393
|
if prefix
|
|
394
|
-
|
|
395
|
-
else if ! hVars[name]?
|
|
396
|
-
result = 'undef'
|
|
394
|
+
return process.env[name]
|
|
397
395
|
else
|
|
398
|
-
|
|
399
|
-
if
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
396
|
+
value = hVars[name]
|
|
397
|
+
if defined(value)
|
|
398
|
+
if isString(value)
|
|
399
|
+
return value
|
|
400
|
+
else
|
|
401
|
+
return JSON.stringify(value)
|
|
402
|
+
else
|
|
403
|
+
return "__#{name}__"
|
|
403
404
|
return line.replace(rx, replacerFunc)
|
|
404
405
|
|
|
405
406
|
# ---------------------------------------------------------------------------
|
package/src/coffee_utils.js
CHANGED
|
@@ -428,18 +428,21 @@ export var replaceVars = function(line, hVars = {}, rx = /__(env\.)?([A-Za-z_]\w
|
|
|
428
428
|
var replacerFunc;
|
|
429
429
|
assert(isHash(hVars), "replaceVars() hVars is not a hash");
|
|
430
430
|
replacerFunc = (match, prefix, name) => {
|
|
431
|
-
var
|
|
431
|
+
var value;
|
|
432
432
|
if (prefix) {
|
|
433
|
-
|
|
434
|
-
} else if (hVars[name] == null) {
|
|
435
|
-
result = 'undef';
|
|
433
|
+
return process.env[name];
|
|
436
434
|
} else {
|
|
437
|
-
|
|
438
|
-
if (
|
|
439
|
-
|
|
435
|
+
value = hVars[name];
|
|
436
|
+
if (defined(value)) {
|
|
437
|
+
if (isString(value)) {
|
|
438
|
+
return value;
|
|
439
|
+
} else {
|
|
440
|
+
return JSON.stringify(value);
|
|
441
|
+
}
|
|
442
|
+
} else {
|
|
443
|
+
return `__${name}__`;
|
|
440
444
|
}
|
|
441
445
|
}
|
|
442
|
-
return result;
|
|
443
446
|
};
|
|
444
447
|
return line.replace(rx, replacerFunc);
|
|
445
448
|
};
|