Files
zipline/src/lib/code.ts
2024-05-22 21:18:55 -07:00

16 lines
369 B
TypeScript
Executable File

import { readFile } from 'fs/promises';
import { extname } from 'path';
export type CodeMeta = {
ext: string;
name: string;
mime: string;
};
export async function isCode(file: string) {
const codeMeta: CodeMeta[] = JSON.parse(await readFile('./code.json', 'utf8'));
const ext = extname(file).slice(1);
return codeMeta.some((meta) => meta.ext === ext);
}