fix: getTemplates
This commit is contained in:
parent
868c4001f6
commit
ac7d4e3645
@ -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('.');
|
||||
|
Loading…
Reference in New Issue
Block a user