aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2023-07-24 18:50:34 +0200
committer0neGal <mail@0negal.com>2023-07-24 18:50:34 +0200
commitc7a3316b1fe29b3b0a4ab053f0a1b6a9b4069f24 (patch)
treef46f29de09e9438677890e92d2eb2ba33e34c524
parent8a47471ae6263aa78ed2a5c4e7a545c2e21c8bcf (diff)
downloadViper-c7a3316b1fe29b3b0a4ab053f0a1b6a9b4069f24.tar.gz
Viper-c7a3316b1fe29b3b0a4ab053f0a1b6a9b4069f24.zip
properly detect if a package has mods
-rw-r--r--src/modules/packages.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/modules/packages.js b/src/modules/packages.js
index d1ea46e..cb0b800 100644
--- a/src/modules/packages.js
+++ b/src/modules/packages.js
@@ -368,6 +368,32 @@ packages.verify = (package_path) => {
return "no-mods";
}
+ // make sure files in the `mods` folder actually are mods, and if
+ // none of them are, then we make sure to return back that are no
+ // mods installed
+ let found_mod = false;
+ let mods = fs.readdirSync(mods_path);
+ for (let i = 0; i < mods.length; i++) {
+ let mod = mods[i];
+ let mod_file = path.join(mod, "mod.json");
+
+ // make sure mod.json exists, and is a file, otherwise, this
+ // is unlikely to be a mod folder
+ if (! fs.existsSync(mod_file)
+ || ! fs.statSync(mod_file).isFile()) {
+ continue;
+ }
+
+ // attempt to read the mod.json file, and if it succeeds, then
+ // this is likely to be a mod
+ let json_data = json(mod_file);
+ if (json_data) {
+ found_mod = true;
+ }
+ }
+
+ if (! found_mod) {return "no-mods"}
+
// all files exist, and everything is just fine
return true;
}