@jdeighan/coffee-utils 7.0.32 → 7.0.33

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jdeighan/coffee-utils",
3
3
  "type": "module",
4
- "version": "7.0.32",
4
+ "version": "7.0.33",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -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
- result = process.env[name]
395
- else if ! hVars[name]?
396
- result = 'undef'
394
+ return process.env[name]
397
395
  else
398
- result = hVars[name]
399
- if ! isString(result)
400
- result = JSON.stringify(result)
401
- return result
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
  # ---------------------------------------------------------------------------
@@ -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 result;
431
+ var value;
432
432
  if (prefix) {
433
- result = process.env[name];
434
- } else if (hVars[name] == null) {
435
- result = 'undef';
433
+ return process.env[name];
436
434
  } else {
437
- result = hVars[name];
438
- if (!isString(result)) {
439
- result = JSON.stringify(result);
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
  };