@jsnw/srv-utils 1.0.7 → 1.0.8
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.
|
@@ -34,7 +34,7 @@ class ConfigLoader {
|
|
|
34
34
|
console.error(loadError.message);
|
|
35
35
|
process.exit(1);
|
|
36
36
|
}
|
|
37
|
-
const [processedYaml, includeErrors] = loader.processIncludes(path, yaml);
|
|
37
|
+
const [processedYaml, includeErrors] = loader.processIncludes((0, node_path_1.dirname)(path), yaml);
|
|
38
38
|
if (includeErrors && includeErrors.length > 0) {
|
|
39
39
|
for (const err of includeErrors)
|
|
40
40
|
console.error(`$include error: ${err.message}`);
|
|
@@ -97,12 +97,12 @@ class ConfigLoader {
|
|
|
97
97
|
return [parsed, null];
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
|
-
* @param {string}
|
|
100
|
+
* @param {string} mainYamlDirname
|
|
101
101
|
* @param yaml
|
|
102
102
|
* @returns {ErrorResult<any, Error[]>}
|
|
103
103
|
* @protected
|
|
104
104
|
*/
|
|
105
|
-
processIncludes(
|
|
105
|
+
processIncludes(mainYamlDirname, yaml) {
|
|
106
106
|
if (typeof yaml !== 'object')
|
|
107
107
|
return yaml;
|
|
108
108
|
const nodesToVisit = [yaml], errors = [];
|
|
@@ -111,7 +111,7 @@ class ConfigLoader {
|
|
|
111
111
|
if (typeof node !== 'object' || Array.isArray(node))
|
|
112
112
|
continue;
|
|
113
113
|
if (node['$include'] && typeof node['$include'] === 'string') {
|
|
114
|
-
const [loadedYaml, loadError] = this.loadYamlFile(
|
|
114
|
+
const [loadedYaml, loadError] = this.loadYamlFile(this.resolveIncludePath(mainYamlDirname, node['$include']));
|
|
115
115
|
delete node['$include'];
|
|
116
116
|
if (loadError) {
|
|
117
117
|
errors.push(loadError);
|
|
@@ -136,5 +136,14 @@ class ConfigLoader {
|
|
|
136
136
|
path = path.replace(PKG_ROOT_REGEX, (0, getRootPackageDirname_1.getRootPackageDirnameSync)() + node_path_1.sep);
|
|
137
137
|
return path;
|
|
138
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* @param {string} fromDirname
|
|
141
|
+
* @param {string} toPath
|
|
142
|
+
* @returns {string}
|
|
143
|
+
* @private
|
|
144
|
+
*/
|
|
145
|
+
resolveIncludePath(fromDirname, toPath) {
|
|
146
|
+
return (0, node_path_1.resolve)(fromDirname, toPath);
|
|
147
|
+
}
|
|
139
148
|
}
|
|
140
149
|
exports.ConfigLoader = ConfigLoader;
|
|
@@ -33,11 +33,18 @@ export declare class ConfigLoader {
|
|
|
33
33
|
*/
|
|
34
34
|
protected validateYaml<T extends z.ZodTypeAny>(data: any, schema: T): ErrorResult<z.infer<T>, Error>;
|
|
35
35
|
/**
|
|
36
|
-
* @param {string}
|
|
36
|
+
* @param {string} mainYamlDirname
|
|
37
37
|
* @param yaml
|
|
38
38
|
* @returns {ErrorResult<any, Error[]>}
|
|
39
39
|
* @protected
|
|
40
40
|
*/
|
|
41
|
-
protected processIncludes(
|
|
41
|
+
protected processIncludes(mainYamlDirname: string, yaml: any): ErrorResult<any, Error[]>;
|
|
42
42
|
private resolvePkgRootPath;
|
|
43
|
+
/**
|
|
44
|
+
* @param {string} fromDirname
|
|
45
|
+
* @param {string} toPath
|
|
46
|
+
* @returns {string}
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
private resolveIncludePath;
|
|
43
50
|
}
|
package/package.json
CHANGED