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