forked from Andy-K-Sparklight/Alicorn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pack.js
40 lines (39 loc) · 1.1 KB
/
pack.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
// eslint-disable-next-line @typescript-eslint/no-var-requires
const compressing = require("compressing");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require("fs-extra");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path");
const tDir = "./out/";
const all = fs.readdirSync(tDir);
try {
fs.mkdirSync(path.join(tDir, "compressed"));
} catch {}
Promise.allSettled(
all.map((e) => {
const c = path.join(tDir, e);
const s = fs.statSync(c);
if (s.isDirectory()) {
if (e.startsWith("Alicorn-win32") || e.startsWith("Alicorn-darwin")) {
return compressing.zip.compressDir(
c,
path.join(tDir, "compressed", e + ".zip"),
{}
);
}
if (e.startsWith("Alicorn-linux")) {
return compressing.tgz.compressDir(
c,
path.join(tDir, "compressed", e + ".tar.gz")
);
}
}
return Promise.resolve();
})
)
.then(() => {
console.log("Compressed output.");
})
.catch((e) => {
console.log("Could not compress output. Caused by: " + e);
});