更新部署服务

This commit is contained in:
aixianling
2022-05-26 18:13:54 +08:00
parent 54c631f208
commit 06a9b238e7
3 changed files with 4 additions and 5 deletions

View File

@@ -10,7 +10,7 @@ module.exports = {
dbUtils.query(sql).then(res => { dbUtils.query(sql).then(res => {
let info = res?.[0] let info = res?.[0]
if (info?.id) { if (info?.id) {
let path = `zips/${info.id}/dist`, zipPath = `./zips/${info.id}.zip` let path = `${info.target}`, zipPath = `./zips/${info.id}.zip`
fse.removeSync(zipPath) fse.removeSync(zipPath)
fse.pathExists(path, (err, exists) => { fse.pathExists(path, (err, exists) => {
console.log(`${path}=========>${exists}`) console.log(`${path}=========>${exists}`)

View File

@@ -20,7 +20,7 @@ module.exports = {
console.log(err) console.log(err)
db.query(`update node_autodeploy set error='${err}' where id='${info.id}'`) db.query(`update node_autodeploy set error='${err}' where id='${info.id}'`)
}) })
} else response.send({code: 1, err: "无法找到git信息"}) } else response.send({code: 1, err: "无法找到部署工程"})
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
response.send({code: 1, err: err.sqlMessage}) response.send({code: 1, err: err.sqlMessage})

View File

@@ -4,9 +4,8 @@ module.exports = info => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fse.emptyDir(`zips/${info.id}`, err => { fse.emptyDir(`zips/${info.id}`, err => {
if (!err) { if (!err) {
execute(`cd zips&&git clone ${info.git} ./${info.id}`) execute(`./${info.updateShell}`)
.then(() => execute(`cd zips/${info.id}&&git checkout ${info.branch}`)) .then(() => execute(`./${info.libShell}`))
.then(() => execute(`cd zips/${info.id}&&npm i&&npm run build`))
.then(() => resolve()) .then(() => resolve())
.catch(errs => { .catch(errs => {
console.log(errs) console.log(errs)