-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanymod.js
48 lines (44 loc) · 1.28 KB
/
anymod.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
39
40
41
42
43
44
45
46
47
48
const axios = require("axios");
const fs = require("fs");
// Change this to match mod id
const modId = "abcxyz";
async function getFileString(path, fileType) {
const dir = await fs.promises.readdir(path, { withFileTypes: true });
let str = "";
for (const dirent of dir) {
if (dirent.name.endsWith(fileType)) {
const fileString = fs.readFileSync(`${path}/${dirent.name}`, "utf-8");
str += `\n${fileString}`;
}
}
return str;
}
async function init() {
const rawCss = await getFileString("./dist/css", "css");
const rawJs = await getFileString("./dist/js", "js");
/**
* Commented this section out so that it doesn't accidentally auto-deploy
* to a live mod.
*
* To make it work in a real scenario, uncomment this section, along with
* updating the modId above to match a real mod.
*/
// return axios({
// method: "put",
// url: `https://api.anymod.com/v0/mods/${modId}`,
// headers: {
// authorization: `Bearer ${process.env.ANYMOD_UPDATE_TOKEN}`,
// },
// data: {
// rawHtml: `<div id="${modId}"></div>`,
// rawCss,
// rawJs,
// },
// })
// .then(process.exit)
// .catch((error) => {
// console.log(error.message);
// process.exit();
// });
}
module.exports = { init, modId };