diff --git a/lib/Builder.js b/lib/Builder.js index 738984d33..e0ceb1814 100644 --- a/lib/Builder.js +++ b/lib/Builder.js @@ -151,7 +151,8 @@ saved ); }) ); - if (result && type === result[0].type) { + if (result && type === result[0]?.type) { + // result elements can be undefined for each key that we did not find this.metadata[type] = result.filter(Boolean).map((element) => element.metadata); } } catch (ex) { diff --git a/lib/metadataTypes/Asset.js b/lib/metadataTypes/Asset.js index aa3021117..cc599a110 100644 --- a/lib/metadataTypes/Asset.js +++ b/lib/metadataTypes/Asset.js @@ -1665,14 +1665,6 @@ class Asset extends MetadataType { break; } } - if (!subType) { - throw new Error( - `Could not find asset with name ${templateName} in ${File.normalizePath([ - templateDir, - ...typeDirArr, - ])}` - ); - } return subType; } /** diff --git a/lib/metadataTypes/MetadataType.js b/lib/metadataTypes/MetadataType.js index 75cc09f75..1a4bf6516 100644 --- a/lib/metadataTypes/MetadataType.js +++ b/lib/metadataTypes/MetadataType.js @@ -359,21 +359,15 @@ class MetadataType { ex ); } catch { - throw new Error( - `${this.definition.type}:: Could not find ./${File.normalizePath([ - retrieveDir, - ...typeDirArr, - fileName + '.json', - ])}.` + // only happening for types that use readSecondaryFolder (e.g. asset) + // if we still have no metadataStr then we have to skip this metadata for all types and hence handle it outside of this catch + } + if (!metadataStr) { + Util.logger.warn( + Util.getGrayMsg(`- skipped ${this.definition.type} ${key}: not found`) ); + return; } - // return; - } - if (!metadataStr) { - Util.logger.info( - Util.getGrayMsg(`- skipped ${this.definition.type} ${key}: not found`) - ); - return; } if (this.definition.stringifyFieldsBeforeTemplate) {