diff options
author | 0neGal <mail@0negal.com> | 2023-07-22 00:29:53 +0200 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2023-07-22 00:29:53 +0200 |
commit | 73a651b63c29e24774c1ba3952a2d6c977101047 (patch) | |
tree | 5cfef0128a8549222ef685ebfacfbc73bd0017ce /src/modules | |
parent | a8174ea74b81db2ada3d0a519cd58de4939a67a8 (diff) | |
download | Viper-73a651b63c29e24774c1ba3952a2d6c977101047.tar.gz Viper-73a651b63c29e24774c1ba3952a2d6c977101047.zip |
unify all mods of a package into one
This means instead of showing the invididual mods inside a package, we
simply show 1 mod/package, we then use the name, description, version
and so forth from the `manifest.json` inside the package folder. Further
we now also support a local `icon.png` file, instead of relying on
remotely stored icons and trying to match names against each other.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/mods.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/modules/mods.js b/src/modules/mods.js index e3ff990..86c78f1 100644 --- a/src/modules/mods.js +++ b/src/modules/mods.js @@ -54,7 +54,9 @@ mods.list = () => { } let get_in_dir = (dir, package_obj) => { + let packaged_mods = []; let files = fs.readdirSync(dir); + files.forEach((file) => { // return early if `file` isn't a folder if (! fs.statSync(path.join(dir, file)).isDirectory()) { @@ -84,6 +86,7 @@ mods.list = () => { } if (obj.package) { + packaged_mods.push(obj.name); obj.author = obj.package.author; } @@ -114,6 +117,27 @@ mods.list = () => { enabled.push(obj); } }) + + if (packaged_mods.length == 0) { + return; + } + + let add_packaged_mods = (mods_array) => { + for (let i = 0; i < mods_array.length; i++) { + if (mods_array[i].package.package_name !== + package_obj.package_name) { + + continue; + } + + mods_array[i].packaged_mods = packaged_mods; + } + + return mods_array; + } + + enabled = add_packaged_mods(enabled); + disbled = add_packaged_mods(disabled); } // get mods in `mods` folder |