configorama 0.4.1 → 0.4.2
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 +10 -10
- package/package.json +1 -1
package/lib/main.js
CHANGED
|
@@ -71,7 +71,7 @@ class Configorama {
|
|
|
71
71
|
// Set opts to pass into JS file calls
|
|
72
72
|
this.opts = Object.assign({}, {
|
|
73
73
|
// Allow for unknown variable syntax to pass through without throwing errors
|
|
74
|
-
|
|
74
|
+
allowUnknownVars: false,
|
|
75
75
|
// Allow undefined to be an end result.
|
|
76
76
|
allowUndefinedValues: false,
|
|
77
77
|
}, options)
|
|
@@ -860,7 +860,7 @@ class Configorama {
|
|
|
860
860
|
|
|
861
861
|
if (nestedVar) {
|
|
862
862
|
const fallbackStr = getFallbackString(splitVars, nestedVar)
|
|
863
|
-
if (!this.opts.
|
|
863
|
+
if (!this.opts.allowUnknownVars) {
|
|
864
864
|
verifyVariable(nestedVar, valueObject, this.variableTypes, this.config)
|
|
865
865
|
}
|
|
866
866
|
|
|
@@ -1194,7 +1194,7 @@ Like so: \${${variableString}, "fallbackValue"\}.`)
|
|
|
1194
1194
|
const nestedVar = findNestedVariable(split, valueObject.originalSource)
|
|
1195
1195
|
|
|
1196
1196
|
if (nestedVar) {
|
|
1197
|
-
if (!this.opts.
|
|
1197
|
+
if (!this.opts.allowUnknownVars) {
|
|
1198
1198
|
verifyVariable(nestedVar, valueObject, this.variableTypes, this.config)
|
|
1199
1199
|
}
|
|
1200
1200
|
const fallbackStr = getFallbackString(split, nestedVar)
|
|
@@ -1248,19 +1248,19 @@ Like so: \${${variableString}, "fallbackValue"\}.`)
|
|
|
1248
1248
|
}
|
|
1249
1249
|
|
|
1250
1250
|
/* Pass through unknown variables */
|
|
1251
|
-
if (this.opts.
|
|
1252
|
-
// console.log('
|
|
1251
|
+
if (this.opts.allowUnknownVars) {
|
|
1252
|
+
// console.log('allowUnknownVars propertyString', propertyString)
|
|
1253
1253
|
const varMatches = propertyString.match(this.variableSyntax)
|
|
1254
|
-
let
|
|
1254
|
+
let allowUnknownVars = propertyString
|
|
1255
1255
|
/* If variables found, encode them for passthrough */
|
|
1256
1256
|
if (varMatches && varMatches.length) {
|
|
1257
1257
|
varMatches.forEach((m) => {
|
|
1258
|
-
|
|
1258
|
+
allowUnknownVars = allowUnknownVars.replace(m, encodeUnknown(m))
|
|
1259
1259
|
})
|
|
1260
1260
|
}
|
|
1261
|
-
// console.log('
|
|
1262
|
-
// console.log('
|
|
1263
|
-
return Promise.resolve(
|
|
1261
|
+
// console.log('allowUnknownVars propertyString:', propertyString)
|
|
1262
|
+
// console.log('allowUnknownVars:', allowUnknownVars)
|
|
1263
|
+
return Promise.resolve(allowUnknownVars)
|
|
1264
1264
|
}
|
|
1265
1265
|
|
|
1266
1266
|
const message = errorMessage.join('\n')
|