更新服务

This commit is contained in:
aixianling
2022-04-01 16:05:56 +08:00
parent 94ce411071
commit 948cc94338
19 changed files with 137 additions and 76 deletions

10
src/tools/exec.js Normal file
View File

@@ -0,0 +1,10 @@
const {exec} = require("child_process");
const execute = cmd => new Promise((resolve, reject) => {
exec(cmd, (err, stdout) => {
if (!err) {
console.log(stdout)
resolve()
} else reject(err)
})
})
module.exports = execute

21
src/tools/zipProject.js Normal file
View File

@@ -0,0 +1,21 @@
const fse = require("fs-extra");
const execute = require("./exec")
module.exports = info => {
return new Promise((resolve, reject) => {
fse.emptyDir(`zips/${info.id}`, err => {
if (!err) {
execute(`cd zips&&git clone ${info.git} ./${info.id}`)
.then(() => execute(`cd zips/${info.id}&&git checkout ${info.branch}`))
.then(() => execute(`cd zips/${info.id}&&npm i&&npm run build`))
.then(() => resolve())
.catch(errs => {
console.log(errs)
reject(errs)
})
} else {
reject(err)
console.log(err)
}
})
})
}