chore(config): Adapted the code to output a new config. Added an error if there is no config file

This commit is contained in:
Данил 2025-03-03 09:44:49 +03:00
parent dd24356e81
commit 1964fd333a
3 changed files with 11 additions and 14 deletions

View file

@ -9,19 +9,16 @@
"version": "1.0.0", "version": "1.0.0",
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
"dependencies": { "dependencies": {
"yaml": "^2.5.0" "hjson": "^3.2.2"
} }
}, },
"node_modules/yaml": { "node_modules/hjson": {
"version": "2.5.0", "version": "3.2.2",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", "resolved": "https://registry.npmjs.org/hjson/-/hjson-3.2.2.tgz",
"integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", "integrity": "sha512-MkUeB0cTIlppeSsndgESkfFD21T2nXPRaBStLtf3cAYA2bVEFdXlodZB0TukwZiobPD1Ksax5DK4RTZeaXCI3Q==",
"license": "ISC", "license": "MIT",
"bin": { "bin": {
"yaml": "bin.mjs" "hjson": "bin/hjson"
},
"engines": {
"node": ">= 14"
} }
} }
} }

View file

@ -17,6 +17,6 @@
"homepage": "https://github.com/Redume/Kekkai#readme", "homepage": "https://github.com/Redume/Kekkai#readme",
"description": "Config management service", "description": "Config management service",
"dependencies": { "dependencies": {
"yaml": "^2.5.0" "hjson": "^3.2.2"
} }
} }

View file

@ -1,10 +1,10 @@
const fs = require('fs'); const fs = require('fs');
const yaml = require('yaml'); const hjson = require('hjson');
const config = () => { const config = () => {
if (!fs.existsSync('../config.yaml')) return; if (!fs.existsSync('../config.hjson')) throw new Error('Config not found');
return yaml.parse(fs.readFileSync('../config.yaml', 'utf-8')); return hjson.parse(fs.readFileSync('../config.hjson', 'utf-8'));
}; };
module.exports = config; module.exports = config;