fix: null error
This commit is contained in:
@@ -55,7 +55,7 @@ export default class Preprocessor {
|
|||||||
*/
|
*/
|
||||||
static getParams(workflow: WorkflowFile): string[] {
|
static getParams(workflow: WorkflowFile): string[] {
|
||||||
const getParamsRecurse = (object: any): string[] => {
|
const getParamsRecurse = (object: any): string[] => {
|
||||||
if (typeof object === 'object') {
|
if (typeof object === 'object' && object !== null) {
|
||||||
// Recursion base case
|
// Recursion base case
|
||||||
if (object.$param) {
|
if (object.$param) {
|
||||||
return [object.$param];
|
return [object.$param];
|
||||||
@@ -141,14 +141,24 @@ export default class Preprocessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const out = object;
|
const out = object;
|
||||||
// for every key (child) of the object
|
|
||||||
Object.keys(object!).forEach((key) => {
|
Object.keys(object!).forEach((key) => {
|
||||||
// if the field has only one key, which is `k`
|
const childValue = (<any>object)[key];
|
||||||
if (Object.keys((<any>object)[key]).length === 1 && (<any>object)[key][k]) {
|
|
||||||
// process the current special tag (init param, hydrate regex...)
|
if (!childValue || typeof childValue !== 'object') {
|
||||||
(<any>out)[key] = f((<any>object)[key][k]);
|
return;
|
||||||
} else {
|
}
|
||||||
initSpecialRecurse((<any>object)[key], k, f);
|
|
||||||
|
try {
|
||||||
|
const childKeys = Object.keys(childValue);
|
||||||
|
|
||||||
|
if (childKeys.length === 1 && childValue[k]) {
|
||||||
|
(<any>out)[key] = f(childValue[k]);
|
||||||
|
} else {
|
||||||
|
initSpecialRecurse(childValue, k, f);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`Error processing key "${key}" in initSpecialRecurse:`, error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return out;
|
return out;
|
||||||
|
|||||||
Reference in New Issue
Block a user