-
Notifications
You must be signed in to change notification settings - Fork 11
/
updater.js
38 lines (36 loc) · 1.28 KB
/
updater.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const fs = require("fs");
const { http, https } = require("follow-redirects");
const path = require("path");
const request = require("request");
const os = require("os");
console.log("updating ...");
request.get(
{
url: "https://raw.githubusercontent.com/snappiee/Donkzz/main/changes.json",
},
function (err, res, body) {
let bod = JSON.parse(body);
bod.c.forEach((a) => {
if (a.includes("/")) {
var i = a.indexOf("/");
var v = a.slice(0, i);
if (!fs.existsSync(path.join(__dirname, `/${v}`))) {
fs.mkdirSync(path.join(__dirname, `/${v}`));
}
}
const newupdater = https.get(
`https://raw.githubusercontent.com/snappiee/Donkzz/main/${a}`,
function (response) {
var updaterstream = fs.createWriteStream(
path.join(__dirname, `/${a}`)
);
response.pipe(updaterstream);
updaterstream.on("finish", () => {
updaterstream.close();
console.log(`${a} updated`);
});
}
);
});
}
);