configorama 0.6.17 → 0.6.18

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/main.js +13 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "configorama",
3
- "version": "0.6.17",
3
+ "version": "0.6.18",
4
4
  "description": "Variable support for configuration files",
5
5
  "main": "src/index.js",
6
6
  "types": "index.d.ts",
package/src/main.js CHANGED
@@ -2566,7 +2566,6 @@ Missing Value ${missingValue} - ${matchedString}
2566
2566
 
2567
2567
  // console.log('variableValues', variableValues)
2568
2568
  return Promise.all(variableValues).then((values) => {
2569
- let deepPropertyStr = propertyString
2570
2569
  let deepProperties = 0
2571
2570
  // console.log('overwrite values', valuesToUse)
2572
2571
  // Extract actual values from metadata objects
@@ -2576,6 +2575,10 @@ Missing Value ${missingValue} - ${matchedString}
2576
2575
  }
2577
2576
  return value
2578
2577
  })
2578
+
2579
+ // Build deep variable parts for reconstruction
2580
+ const deepVariableParts = variableStrings.slice()
2581
+
2579
2582
  extractedValues.forEach((value, index) => {
2580
2583
  // console.log('───────────────────────────────> value', value)
2581
2584
  if (isString(value) && value.match(this.variableSyntax)) {
@@ -2585,14 +2588,17 @@ Missing Value ${missingValue} - ${matchedString}
2585
2588
  // console.log('deepVariable', deepVariable)
2586
2589
  const newValue = cleanVariable(deepVariable, this.variableSyntax, true, `overwrite ${this.callCount}`)
2587
2590
  // console.log(`overwrite newValue ${variableStrings[index]}`, newValue)
2588
- // console.log('variableStrings', variableStrings)
2589
- deepPropertyStr = deepPropertyStr.replace(variableStrings[index], newValue)
2590
- // console.log('deepPropertyString', deepPropertyStr)
2591
+ // Store the deep ref for this part
2592
+ deepVariableParts[index] = newValue
2591
2593
  }
2592
2594
  })
2593
- return deepProperties > 0
2594
- ? Promise.resolve(deepPropertyStr) // return deep variable replacement of original
2595
- : Promise.resolve(extractedValues.find(isValidValue)) // resolve first valid value, else undefined
2595
+
2596
+ if (deepProperties > 0) {
2597
+ // Reconstruct a minimal variable string with deep refs, not the full outer string
2598
+ const reconstructed = '${' + deepVariableParts.join(', ') + '}'
2599
+ return Promise.resolve(reconstructed)
2600
+ }
2601
+ return Promise.resolve(extractedValues.find(isValidValue)) // resolve first valid value, else undefined
2596
2602
  })
2597
2603
  }
2598
2604