@jsnw/srv-utils 1.0.9 → 1.0.11
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/dist/config/config-loader.js +19 -9
- package/package.json +1 -1
|
@@ -91,7 +91,7 @@ class ConfigLoader {
|
|
|
91
91
|
const { data: parsed, error, success } = schema.safeParse(data);
|
|
92
92
|
if (!success) {
|
|
93
93
|
if (error && error instanceof zod_1.ZodError)
|
|
94
|
-
return [null, new Error(`Failed to validate yaml (#1)`)];
|
|
94
|
+
return [null, new Error(`Failed to validate yaml (#1). Error message: ${zod_1.z.prettifyError(error)}`)];
|
|
95
95
|
return [null, new Error(`Failed to validate yaml (#2)`)];
|
|
96
96
|
}
|
|
97
97
|
return [parsed, null];
|
|
@@ -110,15 +110,25 @@ class ConfigLoader {
|
|
|
110
110
|
const node = nodesToVisit[i];
|
|
111
111
|
if (typeof node !== 'object' || Array.isArray(node))
|
|
112
112
|
continue;
|
|
113
|
-
if (node['$include']
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
if (node['$include']) {
|
|
114
|
+
const $includePaths = [];
|
|
115
|
+
if (typeof node['$include'] === 'string') {
|
|
116
|
+
$includePaths.push(node['$include']);
|
|
117
|
+
}
|
|
118
|
+
else if (Array.isArray(node['$include'])) {
|
|
119
|
+
$includePaths.push(...(node['$include']
|
|
120
|
+
.filter(v => v && typeof v === 'string' && v.trim() !== '')));
|
|
118
121
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
delete node['$include'];
|
|
123
|
+
for (const path of $includePaths) {
|
|
124
|
+
const [loadedYaml, loadError] = this.loadYamlFile(this.resolveIncludePath(mainYamlDirname, path));
|
|
125
|
+
if (loadError) {
|
|
126
|
+
errors.push(loadError);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
for (const [k, v] of Object.entries(loadedYaml))
|
|
130
|
+
node[k] = v;
|
|
131
|
+
}
|
|
122
132
|
}
|
|
123
133
|
}
|
|
124
134
|
for (const k of Object.keys(node)) {
|
package/package.json
CHANGED