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:27:56 +01:00
|
|
|
return JSON.parse(fs.readFileSync(join(root, path), 'utf-8'))
|
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) {
|
|
|
|
try {
|
|
|
|
return fs.readFileSync(path, 'utf-8')
|
2024-05-15 17:28:31 +01:00
|
|
|
} catch {
|
2023-10-12 12:33:26 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|