From 1964fd333a9e5b4bd1508d8d4ea77412e6c36ad0 Mon Sep 17 00:00:00 2001 From: Redume Date: Mon, 3 Mar 2025 09:44:49 +0300 Subject: [PATCH] chore(config): Adapted the code to output a new config. Added an error if there is no config file --- shared/config/package-lock.json | 17 +++++++---------- shared/config/package.json | 2 +- shared/config/src/main.js | 6 +++--- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/shared/config/package-lock.json b/shared/config/package-lock.json index 6f0d56d..5e649ba 100644 --- a/shared/config/package-lock.json +++ b/shared/config/package-lock.json @@ -9,19 +9,16 @@ "version": "1.0.0", "license": "GPL-3.0-or-later", "dependencies": { - "yaml": "^2.5.0" + "hjson": "^3.2.2" } }, - "node_modules/yaml": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", - "integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", - "license": "ISC", + "node_modules/hjson": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/hjson/-/hjson-3.2.2.tgz", + "integrity": "sha512-MkUeB0cTIlppeSsndgESkfFD21T2nXPRaBStLtf3cAYA2bVEFdXlodZB0TukwZiobPD1Ksax5DK4RTZeaXCI3Q==", + "license": "MIT", "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14" + "hjson": "bin/hjson" } } } diff --git a/shared/config/package.json b/shared/config/package.json index 00b3ddd..e196982 100644 --- a/shared/config/package.json +++ b/shared/config/package.json @@ -17,6 +17,6 @@ "homepage": "https://github.com/Redume/Kekkai#readme", "description": "Config management service", "dependencies": { - "yaml": "^2.5.0" + "hjson": "^3.2.2" } } diff --git a/shared/config/src/main.js b/shared/config/src/main.js index 97b7b20..d0108d8 100644 --- a/shared/config/src/main.js +++ b/shared/config/src/main.js @@ -1,10 +1,10 @@ const fs = require('fs'); -const yaml = require('yaml'); +const hjson = require('hjson'); 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;