Skip to content

Commit

Permalink
fix: Do not silently swallow missing include/media file errors (#1277)
Browse files Browse the repository at this point in the history
  • Loading branch information
canonic-epicure committed Apr 25, 2020
1 parent d5c2d47 commit 4067f2c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/output/plugins/MarkedPlugin.ts
Expand Up @@ -135,16 +135,20 @@ export class MarkedPlugin extends ContextAwareRendererComponent {
return contents;
}
} else {
this.application.logger.warn('Could not find file to include: ' + path);
return '';
}
});
}

if (this.mediaDirectory) {
text = text.replace(this.mediaPattern, (match: string, path: string) => {
if (FS.existsSync(Path.join(this.mediaDirectory!, path))) {
const fileName = Path.join(this.mediaDirectory!, path);

if (FS.existsSync(fileName) && FS.statSync(fileName).isFile()) {
return this.getRelativeUrl('media') + '/' + path;
} else {
this.application.logger.warn('Could not find media file: ' + fileName);
return match;
}
});
Expand Down

0 comments on commit 4067f2c

Please sign in to comment.