forked from search-future/miyou.tv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist-agent.js
47 lines (42 loc) · 1.18 KB
/
dist-agent.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
const fs = require("fs");
const path = require("path");
const tar = require("tar");
const srcDir = path.join(__dirname, "miyoutv-agent");
const destDir = path.join(__dirname, "build/miyoutv-agent");
const distFile = path.join(__dirname, "build/miyoutv-agent.tar.gz");
const rules = [
["package.json"],
["processes.json"],
["config.sample.json"],
["pm2-install.sh"],
["pm2-uninstall.sh"],
["dist/miyoutv-agent.js"],
["dist/tools/servicelist.js", "tools"],
["tools/chscan.sh", "tools"],
["tools/lists/gr.txt", "tools"],
["tools/lists/catv.txt", "tools"],
["tools/lists/bs.txt", "tools"],
["tools/lists/cs.txt", "tools"]
];
rules.sort(([, a = ""], [, b = ""]) => {
return path.join(destDir, a) > path.join(destDir, b) ? 1 : -1;
});
for (const [src, dest = ""] of rules) {
if (!fs.existsSync(path.join(destDir, dest))) {
fs.mkdirSync(path.join(destDir, dest), { recursive: true });
}
fs.copyFileSync(
path.join(srcDir, src),
path.join(destDir, dest, path.basename(src))
);
}
tar.c(
{
file: distFile,
sync: true,
cwd: path.join(destDir, ".."),
gzip: true
},
[path.basename(destDir)]
);
fs.unlinkSync(path.join(destDir, "package.json"));