@jdeighan/coffee-utils 7.0.13 → 7.0.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jdeighan/coffee-utils",
3
3
  "type": "module",
4
- "version": "7.0.13",
4
+ "version": "7.0.14",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -379,3 +379,17 @@ export strcat = (lItems...) ->
379
379
  for item in lItems
380
380
  str += item.toString()
381
381
  return str
382
+
383
+ # ---------------------------------------------------------------------------
384
+
385
+ export replaceVars = (line, hVars) ->
386
+
387
+ replacerFunc = (match, prefix, name) =>
388
+ return if prefix then process.env[name] else hVars[name].toString()
389
+
390
+ return line.replace(///
391
+ __
392
+ (env\.)?
393
+ ([A-Za-z_]\w*)
394
+ __
395
+ ///g, replacerFunc)
@@ -408,3 +408,16 @@ export var strcat = function(...lItems) {
408
408
  }
409
409
  return str;
410
410
  };
411
+
412
+ // ---------------------------------------------------------------------------
413
+ export var replaceVars = function(line, hVars) {
414
+ var replacerFunc;
415
+ replacerFunc = (match, prefix, name) => {
416
+ if (prefix) {
417
+ return process.env[name];
418
+ } else {
419
+ return hVars[name].toString();
420
+ }
421
+ };
422
+ return line.replace(/__(env\.)?([A-Za-z_]\w*)__/g, replacerFunc);
423
+ };