fix: getTemplates
This commit is contained in:
parent
868c4001f6
commit
ac7d4e3645
@ -2,16 +2,13 @@ import { isDev } from "./common";
|
|||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
export async function getTemplates() {
|
export async function getTemplates() {
|
||||||
const templatePath = isDev ? './templates.json' : '/app/templates.json';
|
const templatePath = isDev ? './templates.json' : '/app/templates.json';
|
||||||
const open = await fs.open(templatePath, 'r');
|
|
||||||
let data;
|
|
||||||
try {
|
try {
|
||||||
data = await open.readFile({ encoding: 'utf-8' });
|
const ts = await fs.readFile(templatePath, 'utf8')
|
||||||
return JSON.parse(data);
|
if (ts) {
|
||||||
} catch (error) {
|
return JSON.parse(ts);
|
||||||
return []
|
}
|
||||||
} finally {
|
} catch (error) { }
|
||||||
await open?.close()
|
return [];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const compareSemanticVersions = (a: string, b: string) => {
|
const compareSemanticVersions = (a: string, b: string) => {
|
||||||
const a1 = a.split('.');
|
const a1 = a.split('.');
|
||||||
|
Loading…
Reference in New Issue
Block a user