21 lines
470 B
JavaScript
21 lines
470 B
JavaScript
const fs = require("fs/promises");
|
|
const path = require("path");
|
|
|
|
let cached = null;
|
|
|
|
async function loadToolsConfig(configPath = "tools/config.json") {
|
|
const resolved = path.resolve(configPath);
|
|
if (cached && cached.path === resolved) {
|
|
return cached.data;
|
|
}
|
|
|
|
const raw = await fs.readFile(resolved, "utf8");
|
|
const data = JSON.parse(raw);
|
|
cached = { path: resolved, data };
|
|
return data;
|
|
}
|
|
|
|
module.exports = {
|
|
loadToolsConfig,
|
|
};
|