-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb.js
55 lines (49 loc) · 1.52 KB
/
web.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
const child_process = require("child_process");
const fs = require("fs");
const compressing = require('compressing');
const address = "E:\\芜湖\\sc-whmc-web";
const desk = "C:\\Users\\yiduo\\OneDrive\\桌面"
// 递归删除文件
function deleteFolder(path) {
var files = [];
if( fs.existsSync(path) ) {
files = fs.readdirSync(path);
files.forEach(function(file,index){
var curPath = path + "/" + file;
if(fs.statSync(curPath).isDirectory()) { // recurse
deleteFolder(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
};
async function commandHandle (command){
return new Promise((resolve, reject) => {
child_process.exec(
command,
{ cwd: address },
function (error, stdout, stderr) {
if (error !== null) {
console.log("exec error: " + error);
reject()
} else {
console.log(stdout);
resolve()
}
}
);
});
};
async function start() {
deleteFolder(address + '\\dist')
await commandHandle('git pull')
await commandHandle('npm run gov:prod')
compressing.zip.compressDir(`${address}\\dist`, `${desk}\\dist.zip`).then((res=>{
console.log(res,'-res')
})).catch((err=>{
console.log(err)
}));
}
start()