configorama 0.4.8 → 0.4.9

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/lib/main.js CHANGED
@@ -438,6 +438,10 @@ class Configorama {
438
438
  })
439
439
  }
440
440
  runFunction(variableString) {
441
+ /* If json object value return it */
442
+ if (variableString.match(/^\s*{/) && variableString.match(/}\s*$/)) {
443
+ return variableString
444
+ }
441
445
  // console.log('runFunction', variableString)
442
446
  var hasFunc = funcRegex.exec(variableString)
443
447
  // TODO finish Function handling. Need to move this down below resolver to resolve inner refs first
@@ -105,6 +105,11 @@ function matchOutermostBraces(text) {
105
105
  return results;
106
106
  }
107
107
 
108
+ // https://regex101.com/r/XIltbc/1
109
+ const KEY_OBJECT = /^[ \t]*[^":\s]*:\s+\{/gm
110
+
111
+ const INNER_ARRAY = /\[(?:[^\[\]])*\]/g
112
+
108
113
  function preProcess(ymlStr = '') {
109
114
  /*
110
115
  return ymlStr
@@ -115,7 +120,7 @@ function preProcess(ymlStr = '') {
115
120
  // out -> y: !Not [!Equals [!Join ['', "${param:xyz}"]]]
116
121
  const arrayBracketMatches = ymlStr && ymlStr.match(
117
122
  // /\[(?:[^\[\]]+|)*\]/gm
118
- /\[(?:[^\[\]])*\]/g
123
+ INNER_ARRAY
119
124
  )
120
125
  if (arrayBracketMatches) {
121
126
  // console.log('arrayBracketMatches', arrayBracketMatches)
@@ -146,7 +151,7 @@ function preProcess(ymlStr = '') {
146
151
  }
147
152
 
148
153
  /* If have yaml object and vars not wrapped in quotes, wrap them */
149
- if (ymlStr.match(/^[ \t]*[^:\n]*:\s*\{/gm)) {
154
+ if (ymlStr.match(KEY_OBJECT)) {
150
155
  const hasObjects = matchOutermostBraces(ymlStr)
151
156
  // console.log('hasObjects', hasObjects)
152
157
  if (hasObjects && hasObjects.length) {
@@ -171,9 +176,7 @@ function preProcess(ymlStr = '') {
171
176
  })
172
177
  }
173
178
  }
174
-
175
179
  // console.log('ymlStr', ymlStr)
176
-
177
180
  return ymlStr
178
181
  }
179
182
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "configorama",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "description": "Variable support for configuration files",
5
5
  "main": "lib/index.js",
6
6
  "files": [