cobalt/api/src/misc/load-from-fs.js

21 lines
411 B
JavaScript
Raw Normal View History

import * as fs from "fs";
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const root = join(
dirname(fileURLToPath(import.meta.url)),
'../../'
);
export function loadJSON(path) {
try {
return JSON.parse(loadFile(path))
2024-05-15 17:28:31 +01:00
} catch {
return false
}
}
export function loadFile(path) {
return fs.readFileSync(join(root, path), 'utf-8')
}