-
Notifications
You must be signed in to change notification settings - Fork 223
/
release.js
59 lines (49 loc) · 1.54 KB
/
release.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
const {join} = require("path");
const {mkdirSync, rmSync, readdirSync, statSync, writeFileSync} = require("fs");
// 发布初始化 清空 `./_release` 目录
const init = () => {
const releasePath = join(__dirname, '_release')
rmSync(releasePath, {recursive: true, force: true});
mkdirSync(releasePath);
}
// 获取发布文件列表 生成发布文件日志
const get = () => {
const releasePath = join(__dirname, "_release")
const files = readdirSync(releasePath).map(item => {
return {
path: join(releasePath, item),
name: `./_release/${item}`
}
}).filter(item => {
return statSync(item.path).isFile()
}).map(item => item.name) || []
const result = files.join("\n")
writeFileSync(join(__dirname, "_release_files"), result)
console.log(result)
}
// 清理 core dist 文件 github action 中使用
const clear = () => {
rmSync(join(__dirname, 'packages/ctool-core/dist/.git'), {recursive: true, force: true});
rmSync(join(__dirname, 'packages/ctool-core/dist/.nojekyll'), {force: true});
}
const run = () => {
const arguments = process.argv.splice(2) || [];
let type = "init"
if (arguments.length > 0) {
type = `${arguments[0]}`;
}
switch (type) {
case "init":
init();
break;
case "get":
get();
break;
case "clear":
clear();
break;
default :
console.error("type error node ./release.js [init|get|clear]")
}
}
run();