@itgorillaz/configify 1.1.2 → 1.2.3
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.
|
@@ -2,7 +2,7 @@ export declare class Variables {
|
|
|
2
2
|
private static readonly ESCAPE_PATTERN;
|
|
3
3
|
private static readonly UNESCAPED_PATTERN;
|
|
4
4
|
private static readonly EXPANSION_GROUP_PATTERN;
|
|
5
|
-
static expand(record: Record<string,
|
|
5
|
+
static expand(record: Record<string, unknown>): Record<string, unknown>;
|
|
6
6
|
private static interpolate;
|
|
7
7
|
private static escapeSequences;
|
|
8
8
|
private static lastIndexOf;
|
|
@@ -6,11 +6,17 @@ class Variables {
|
|
|
6
6
|
const expanded = {};
|
|
7
7
|
for (const key in record) {
|
|
8
8
|
const value = record[key];
|
|
9
|
-
|
|
9
|
+
const interpolated = this.interpolate(value, record);
|
|
10
|
+
expanded[key] =
|
|
11
|
+
typeof interpolated === 'string'
|
|
12
|
+
? this.escapeSequences(interpolated)
|
|
13
|
+
: interpolated;
|
|
10
14
|
}
|
|
11
15
|
return expanded;
|
|
12
16
|
}
|
|
13
17
|
static interpolate(value, record) {
|
|
18
|
+
if (typeof value !== 'string')
|
|
19
|
+
return value;
|
|
14
20
|
const lastUnescapedDollarSignIndex = this.lastIndexOf(value, this.UNESCAPED_PATTERN);
|
|
15
21
|
if (lastUnescapedDollarSignIndex === -1)
|
|
16
22
|
return value;
|
|
@@ -18,7 +24,7 @@ class Variables {
|
|
|
18
24
|
const match = rightMostGroup.match(this.EXPANSION_GROUP_PATTERN);
|
|
19
25
|
if (match != null) {
|
|
20
26
|
const [, group, variableName, defaultValue] = match;
|
|
21
|
-
return this.interpolate(value.replace(group, defaultValue || record[variableName] || ''), record);
|
|
27
|
+
return this.interpolate(value.replace(group, defaultValue || `${record[variableName]}` || ''), record);
|
|
22
28
|
}
|
|
23
29
|
return value;
|
|
24
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variables.js","sourceRoot":"","sources":["../../../src/interpolation/variables.ts"],"names":[],"mappings":";;;AAQA,MAAa,SAAS;IA8BpB,MAAM,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"variables.js","sourceRoot":"","sources":["../../../src/interpolation/variables.ts"],"names":[],"mappings":";;;AAQA,MAAa,SAAS;IA8BpB,MAAM,CAAC,MAAM,CAAC,MAA+B;QAC3C,MAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACzB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAC1B,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACrD,QAAQ,CAAC,GAAG,CAAC;gBACX,OAAO,YAAY,KAAK,QAAQ;oBAC9B,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC;oBACpC,CAAC,CAAC,YAAY,CAAC;QACrB,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IASO,MAAM,CAAC,WAAW,CACxB,KAAc,EACd,MAA+B;QAE/B,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAE5C,MAAM,4BAA4B,GAAG,IAAI,CAAC,WAAW,CACnD,KAAK,EACL,IAAI,CAAC,iBAAiB,CACvB,CAAC;QAEF,IAAI,4BAA4B,KAAK,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QAEtD,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACjE,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAEjE,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,MAAM,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC;YACpD,OAAO,IAAI,CAA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