#206 - Removal of the front matter parsing error notification

This commit is contained in:
Elio Struyf
2021-12-20 20:38:56 +01:00
parent 87e80ccfe9
commit 6da3ddb5dd
2 changed files with 4 additions and 20 deletions
+3 -19
View File
@@ -35,9 +35,9 @@ export class ArticleHelper {
* Retrieve the file's front matter by its path
* @param filePath
*/
public static getFrontMatterByPath(filePath: string, surpressNotification: boolean = false) {
public static getFrontMatterByPath(filePath: string) {
const file = fs.readFileSync(filePath, { encoding: "utf-8" });
return ArticleHelper.parseFile(file, filePath, surpressNotification);
return ArticleHelper.parseFile(file, filePath);
}
/**
@@ -228,10 +228,9 @@ export class ArticleHelper {
* @param fileContents
* @returns
*/
private static parseFile(fileContents: string, fileName: string, surpressNotification: boolean = false): matter.GrayMatterFile<string> | null {
private static parseFile(fileContents: string, fileName: string): matter.GrayMatterFile<string> | null {
try {
const commaSeparated = Settings.get<string[]>(SETTING_COMMA_SEPARATED_FIELDS);
const diagnostics: Diagnostic[] = [];
if (fileContents) {
const language: string = getFmLanguage();
@@ -288,21 +287,6 @@ export class ArticleHelper {
}]);
}
}
if (!surpressNotification) {
if (this.notifiedFiles.indexOf(fileName) === -1) {
Notifications.error(`There seems to be an issue parsing the content its front matter. FileName: ${basename(fileName)}. ERROR: ${error.message || error}`, ...items).then((result: any) => {
if (result?.title) {
const item = items.find(i => i.title === result.title);
if (item) {
item.action();
}
}
});
this.notifiedFiles.push(fileName);
}
}
}
return null;
}
+1 -1
View File
@@ -67,7 +67,7 @@ export class CustomScript {
if (folder.lastModified.length > 0) {
for await (const file of folder.lastModified) {
try {
const article = ArticleHelper.getFrontMatterByPath(file.filePath, true);
const article = ArticleHelper.getFrontMatterByPath(file.filePath);
if (article) {
const crntOutput = await CustomScript.runScript(wsPath, article, file.filePath, script);
if (crntOutput) {