@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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itgorillaz/configify",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "NestJS Config on Steroids",
|
|
5
5
|
"author": "tommelo",
|
|
6
6
|
"private": false,
|
|
@@ -44,19 +44,19 @@
|
|
|
44
44
|
"@nestjs/testing": "^10.3.7",
|
|
45
45
|
"@types/jest": "29.5.12",
|
|
46
46
|
"@types/js-yaml": "^4.0.9",
|
|
47
|
-
"@types/node": "20.
|
|
47
|
+
"@types/node": "20.14.10",
|
|
48
48
|
"@types/supertest": "^6.0.2",
|
|
49
49
|
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
|
50
50
|
"@typescript-eslint/parser": "^7.4.0",
|
|
51
|
-
"eslint": "^8.0.
|
|
51
|
+
"eslint": "^8.0.0 || ^9.0.0",
|
|
52
52
|
"eslint-config-prettier": "^9.1.0",
|
|
53
53
|
"eslint-plugin-prettier": "^5.1.3",
|
|
54
54
|
"jest": "29.7.0",
|
|
55
55
|
"prettier": "^3.2.5",
|
|
56
|
-
"prettier-plugin-organize-imports": "^
|
|
56
|
+
"prettier-plugin-organize-imports": "^4.0.0",
|
|
57
57
|
"source-map-support": "^0.5.20",
|
|
58
|
-
"supertest": "^
|
|
59
|
-
"ts-jest": "29.
|
|
58
|
+
"supertest": "^7.0.0",
|
|
59
|
+
"ts-jest": "29.2.2",
|
|
60
60
|
"ts-loader": "^9.2.3",
|
|
61
61
|
"ts-node": "^10.0.0",
|
|
62
62
|
"tsconfig-paths": "4.2.0",
|
|
@@ -33,14 +33,18 @@ export class Variables {
|
|
|
33
33
|
/**
|
|
34
34
|
* Expands the variables of the given object.
|
|
35
35
|
*
|
|
36
|
-
* @param {Record<string,
|
|
37
|
-
* @returns {Record<string,
|
|
36
|
+
* @param {Record<string, unknown>} record The object
|
|
37
|
+
* @returns {Record<string, unknown>} The expanded object
|
|
38
38
|
*/
|
|
39
|
-
static expand(record: Record<string,
|
|
39
|
+
static expand(record: Record<string, unknown>): Record<string, unknown> {
|
|
40
40
|
const expanded = {};
|
|
41
41
|
for (const key in record) {
|
|
42
42
|
const value = record[key];
|
|
43
|
-
|
|
43
|
+
const interpolated = this.interpolate(value, record);
|
|
44
|
+
expanded[key] =
|
|
45
|
+
typeof interpolated === 'string'
|
|
46
|
+
? this.escapeSequences(interpolated)
|
|
47
|
+
: interpolated;
|
|
44
48
|
}
|
|
45
49
|
return expanded;
|
|
46
50
|
}
|
|
@@ -53,9 +57,11 @@ export class Variables {
|
|
|
53
57
|
* @returns
|
|
54
58
|
*/
|
|
55
59
|
private static interpolate(
|
|
56
|
-
value:
|
|
57
|
-
record: Record<string,
|
|
58
|
-
):
|
|
60
|
+
value: unknown,
|
|
61
|
+
record: Record<string, unknown>,
|
|
62
|
+
): unknown {
|
|
63
|
+
if (typeof value !== 'string') return value;
|
|
64
|
+
|
|
59
65
|
const lastUnescapedDollarSignIndex = this.lastIndexOf(
|
|
60
66
|
value,
|
|
61
67
|
this.UNESCAPED_PATTERN,
|
|
@@ -69,7 +75,7 @@ export class Variables {
|
|
|
69
75
|
if (match != null) {
|
|
70
76
|
const [, group, variableName, defaultValue] = match;
|
|
71
77
|
return this.interpolate(
|
|
72
|
-
value.replace(group, defaultValue || record[variableName] || ''),
|
|
78
|
+
value.replace(group, defaultValue || `${record[variableName]}` || ''),
|
|
73
79
|
record,
|
|
74
80
|
);
|
|
75
81
|
}
|