aboutsummaryrefslogtreecommitdiff
path: root/src/utils.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-02-19 14:25:18 +0100
committerGitHub <noreply@github.com>2022-02-19 14:25:18 +0100
commit39da6eeecdb184e05f93ad1a8aaa1a2a95df333a (patch)
tree74b6be3a0edebe8df31c95d337ec63a64433f053 /src/utils.js
parentee7dab5b056e254bff828a9b9f6d77be2287b935 (diff)
parent9e539d3d3df62df39b9a67ecf1c24734d6f8779b (diff)
downloadViper-39da6eeecdb184e05f93ad1a8aaa1a2a95df333a.tar.gz
Viper-39da6eeecdb184e05f93ad1a8aaa1a2a95df333a.zip
Merge pull request #81 from 0neGal/drag-drop
feat: drag and drop to install mods
Diffstat (limited to 'src/utils.js')
-rw-r--r--src/utils.js62
1 files changed, 33 insertions, 29 deletions
diff --git a/src/utils.js b/src/utils.js
index 1448007..2ea91cd 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -544,40 +544,44 @@ const mods = {
}
try {
- fs.createReadStream(mod).pipe(unzip.Extract({path: cache}))
- .on("finish", () => {
- setTimeout(() => {
- let manifest = path.join(cache, "manifest.json");
- if (fs.existsSync(manifest)) {
- files = fs.readdirSync(path.join(cache, "mods"));
- if (fs.existsSync(path.join(cache, "mods/mod.json"))) {
- if (mods.install(path.join(cache, "mods"), require(manifest).name, manifest, true)) {
- return true;
- }
- } else {
- for (let i = 0; i < files.length; i++) {
- let mod = path.join(cache, "mods", files[i]);
- if (fs.statSync(mod).isDirectory()) {
- setTimeout(() => {
- if (mods.install(mod, false, manifest)) {return true};
- }, 1000)
+ if (mod.replace(/.*\./, "").toLowerCase() == "zip") {
+ fs.createReadStream(mod).pipe(unzip.Extract({path: cache}))
+ .on("finish", () => {
+ setTimeout(() => {
+ let manifest = path.join(cache, "manifest.json");
+ if (fs.existsSync(manifest)) {
+ files = fs.readdirSync(path.join(cache, "mods"));
+ if (fs.existsSync(path.join(cache, "mods/mod.json"))) {
+ if (mods.install(path.join(cache, "mods"), require(manifest).name, manifest, true)) {
+ return true;
+ }
+ } else {
+ for (let i = 0; i < files.length; i++) {
+ let mod = path.join(cache, "mods", files[i]);
+ if (fs.statSync(mod).isDirectory()) {
+ setTimeout(() => {
+ if (mods.install(mod, false, manifest)) {return true};
+ }, 1000)
+ }
}
- }
- if (files.length == 0) {
- ipcMain.emit("failedmod");
- return notamod();
+ if (files.length == 0) {
+ ipcMain.emit("failedmod");
+ return notamod();
+ }
}
- }
- return notamod();
- }
+ return notamod();
+ }
- if (mods.install(cache)) {
- installed();
- } else {return notamod()}
- }, 1000)
- });
+ if (mods.install(cache)) {
+ installed();
+ } else {return notamod()}
+ }, 1000)
+ });
+ } else {
+ return notamod();
+ }
}catch(err) {return notamod()}
}
},