Skip to content

Commit

Permalink
fix: node 16 error parsing issue (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele authored Sep 9, 2021
1 parent c99198b commit 54e1fdd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/convert/transformers/staticResourceMetadataTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ export class StaticResourceMetadataTransformer extends BaseMetadataTransformer {
}

private async getContentType(component: SourceComponent): Promise<string> {
try {
return ((await component.parseXml()).StaticResource as JsonMap).contentType as string;
} catch (e) {
if ((e as Error).message.includes("Cannot read property 'contentType' of undefined")) {
throw new LibraryError('error_static_resource_missing_resource_file', [
join('staticresources', component.name),
]);
}
const resource = (await component.parseXml()).StaticResource as JsonMap;

if (!resource || !resource.hasOwnProperty('contentType')) {
throw new LibraryError('error_static_resource_missing_resource_file', [
join('staticresources', component.name),
]);
}

return resource.contentType as string;
}

private getExtensionFromType(contentType: string): string {
Expand Down

0 comments on commit 54e1fdd

Please sign in to comment.