Skip to content

Commit

Permalink
#1324: handle template-source-not-found more gracefully for asset
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed May 16, 2024
1 parent 1114c4c commit 22f06c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
3 changes: 2 additions & 1 deletion lib/Builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 0 additions & 8 deletions lib/metadataTypes/Asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
/**
Expand Down
20 changes: 7 additions & 13 deletions lib/metadataTypes/MetadataType.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 22f06c8

Please sign in to comment.