Ignore errors in getContentOfType

This commit is contained in:
Cohee 2024-09-20 08:31:25 +00:00
parent 5001187b3c
commit d7a37298ab
1 changed files with 16 additions and 12 deletions

View File

@ -232,18 +232,22 @@ function getContentOfType(type, format) {
if (!item.folder) {
continue;
}
const filePath = path.join(item.folder, item.filename);
const fileContent = fs.readFileSync(filePath);
switch (format) {
case 'json':
files.push(JSON.parse(fileContent.toString()));
break;
case 'string':
files.push(fileContent.toString());
break;
case 'raw':
files.push(fileContent);
break;
try {
const filePath = path.join(item.folder, item.filename);
const fileContent = fs.readFileSync(filePath);
switch (format) {
case 'json':
files.push(JSON.parse(fileContent.toString()));
break;
case 'string':
files.push(fileContent.toString());
break;
case 'raw':
files.push(fileContent);
break;
}
} catch {
// Ignore errors
}
}
return files;