-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathzip-source.js
65 lines (59 loc) · 1.29 KB
/
zip-source.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const AdmZip = require("adm-zip");
const fs = require("fs");
const date = new Date();
const zip = new AdmZip();
const pad = (inString, length, padCharacter) => {
const stringLength = inString.toString().length;
if (stringLength < length) {
for (let i = 0; i < length - stringLength; i++) {
inString = padCharacter + inString;
}
}
return inString;
};
zip.addLocalFolder("../nekocap", "", (filename) => {
const excludedFiles = [
".env",
".env.prod",
"dist/",
"docker/",
".git",
".vscode",
"node_modules",
"server-fonts",
"webdist",
".eslintcache",
"Dockerfile",
".zip",
"package-backup.json",
"zip-source.js",
".next",
"pages/",
"public/",
"next-env.d.ts",
"next-i18next.config.js",
"next.config.js",
".release-it.js",
"webserver.js",
"server.js",
];
for (let i = 0; i < excludedFiles.length; i++) {
if (filename.indexOf(excludedFiles[i]) >= 0) {
return false;
}
}
return true;
});
const filename = `./nekocap-source-${date.getFullYear()}-${pad(
date.getMonth() + 1,
2,
"0"
)}-${pad(date.getDate(), 2, "0")}-${pad(date.getHours(), 2, "0")}-${pad(
date.getMinutes(),
2,
"0"
)}.zip`;
if (fs.existsSync(filename)) {
fs.unlinkSync(filename);
}
zip.writeZip(filename);