Page de statistiques
This commit is contained in:
20
tools/lib/config.js
Normal file
20
tools/lib/config.js
Normal file
@@ -0,0 +1,20 @@
|
||||
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,
|
||||
};
|
||||
Reference in New Issue
Block a user