mirror of
https://github.com/tcgdex/compiler.git
synced 2025-04-22 18:52:08 +00:00
30 lines
836 B
TypeScript
30 lines
836 B
TypeScript
import { promises as fs} from "fs"
|
|
import * as fsSync from 'fs'
|
|
import { IllustratorSimple } from "@tcgdex/sdk/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
|
|
}
|
|
}
|