精简代码

This commit is contained in:
aixianling
2022-05-26 18:29:26 +08:00
parent c45f0b6faf
commit c33e62cdeb
2 changed files with 3 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
const db = require("../../utils/dbUitls");
const zip = require("../../tools/zipProject")
const dayjs = require("dayjs")
const execute = require("./exec");
module.exports = {
action: "/node/autodeploy/getZip",
method: "post",
@@ -11,10 +11,8 @@ module.exports = {
let info = res?.[0]
if (info?.id) {
db.query(`update node_autodeploy set download=null,error=null where id='${info.id}'`)
setTimeout(() => {
response.send({code: 0})
}, 2000)
zip(info).then(() => {
execute(`${info.updateShell}`).then(() => execute(`${info.libShell}`))
.then(() => {
db.query(`update node_autodeploy set download='${dayjs().format("YYYY-MM-DD HH:mm:ss")}',error='' where id='${info.id}'`)
}).catch(err => {
console.log(err)

View File

@@ -1,20 +0,0 @@
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(`${info.updateShell}`)
.then(() => execute(`${info.libShell}`))
.then(() => resolve())
.catch(errs => {
console.log(errs)
reject(errs)
})
} else {
reject(err)
console.log(err)
}
})
})
}