compiler/endpoints/illustratorUtil.ts
Florian Bouillon cee4181627
Updated Utils
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
2020-03-10 14:39:38 +01:00

30 lines
842 B
TypeScript

import { promises as fs} from "fs"
import * as fsSync from 'fs'
import { IllustratorSimple } from "../sdk/dist/types/interfaces/Illustrator"
export const illustratorsFile = "./generated/illustrators.json"
let illustratorsCache: Array<string> = []
export async function fetchIllustrators(): Promise<Array<string>> {
if (illustratorsCache.length === 0) {
illustratorsCache = JSON.parse(await (await fs.readFile(illustratorsFile)).toString())
}
return illustratorsCache
}
export function fetchIllustratorsSync(): Array<string> {
if (illustratorsCache.length === 0) {
illustratorsCache = JSON.parse(fsSync.readFileSync(illustratorsFile).toString())
}
return illustratorsCache
}
export function illustratorToIllustratorSimple(illustrator: string, index: number): IllustratorSimple {
return {
id: index,
name: illustrator
}
}