fix: getTemplates

This commit is contained in:
Andras Bacsai 2022-11-11 14:19:42 +01:00
parent 868c4001f6
commit ac7d4e3645

View File

@ -2,16 +2,13 @@ import { isDev } from "./common";
import fs from 'fs/promises';
export async function getTemplates() {
const templatePath = isDev ? './templates.json' : '/app/templates.json';
const open = await fs.open(templatePath, 'r');
let data;
try {
data = await open.readFile({ encoding: 'utf-8' });
return JSON.parse(data);
} catch (error) {
return []
} finally {
await open?.close()
}
const ts = await fs.readFile(templatePath, 'utf8')
if (ts) {
return JSON.parse(ts);
}
} catch (error) { }
return [];
}
const compareSemanticVersions = (a: string, b: string) => {
const a1 = a.split('.');