fix: no tags error

This commit is contained in:
Andras Bacsai
2022-11-11 09:25:02 +01:00
parent 3c94723b23
commit ae2d3ebb48
6 changed files with 39 additions and 27 deletions

View File

@@ -22,15 +22,22 @@ const compareSemanticVersions = (a: string, b: string) => {
return b1.length - a1.length;
};
export async function getTags(type: string) {
if (type) {
const tagsPath = isDev ? './tags.json' : '/app/tags.json';
const data = await fs.readFile(tagsPath, 'utf8')
let tags = JSON.parse(data)
if (tags) {
tags = tags.find((tag: any) => tag.name.includes(type))
tags.tags = tags.tags.sort(compareSemanticVersions).reverse();
return tags
try {
if (type) {
const tagsPath = isDev ? './tags.json' : '/app/tags.json';
const data = await fs.readFile(tagsPath, 'utf8')
let tags = JSON.parse(data)
if (tags) {
tags = tags.find((tag: any) => tag.name.includes(type))
tags.tags = tags.tags.sort(compareSemanticVersions).reverse();
return tags
}
}
} catch (error) {
return []
}
return []
}