mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 20:59:59 +00:00
21 lines
411 B
JavaScript
21 lines
411 B
JavaScript
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 loadFile(path) {
|
|
return fs.readFileSync(join(root, path), 'utf-8')
|
|
}
|
|
|
|
export function loadJSON(path) {
|
|
try {
|
|
return JSON.parse(loadFile(path))
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|