追加跟踪细粒度
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
const {exec} = require("child_process");
|
const {exec} = require("child_process");
|
||||||
|
|
||||||
class Process {
|
class Process {
|
||||||
constructor(cmd) {
|
constructor(cmd, cb) {
|
||||||
this.cmd = cmd
|
this.cmd = cmd
|
||||||
this.pid = exec(cmd, {windowsHide: true, encoding: "utf8"});
|
this.pid = exec(cmd, {windowsHide: true, encoding: "utf8"});
|
||||||
|
this.callback = cb
|
||||||
}
|
}
|
||||||
|
|
||||||
static new(cmd) {
|
static new(cmd) {
|
||||||
@@ -28,6 +29,7 @@ class Process {
|
|||||||
})
|
})
|
||||||
this.pid.stdout.on('data', data => {
|
this.pid.stdout.on('data', data => {
|
||||||
console.log(data)
|
console.log(data)
|
||||||
|
this.callback?.()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,17 +15,18 @@ const handleZip = (id, ws) => {
|
|||||||
wxwork: 'base-wxcp',
|
wxwork: 'base-wxcp',
|
||||||
mp: 'dvcp_v2_wxmp'
|
mp: 'dvcp_v2_wxmp'
|
||||||
}[info.type] || {}
|
}[info.type] || {}
|
||||||
let path = `../${buildPath}`, {dist} = info
|
let path = `../${buildPath}`, {dist} = info, progress
|
||||||
dist = dist || `../zips/${info.name}v${info.version || "1.0.0"}`
|
dist = dist || `../zips/${info.name}v${info.version || "1.0.0"}`
|
||||||
Promise.all([
|
Promise.all([
|
||||||
db.query(`update node_custom_config set download=null,error=null,zipTime='${dayjs().format("YYYY-MM-DD HH:mm:ss")}' where ${uniCon}`),
|
db.query(`update node_custom_config set download=null,error=null,zipTime='${dayjs().format("YYYY-MM-DD HH:mm:ss")}' where ${uniCon}`),
|
||||||
process.new(`./shell/update.sh ${info.name} ${path}`)])
|
process.new(`./shell/update.sh ${info.name} ${path}`)])
|
||||||
.then(() => sendMessage({code: 0, progress: 30}))
|
.then(() => progress = 30, sendMessage({code: 0, progress}))
|
||||||
.then(() => pid = new process(`cd ${path}&&npm run apps&&node bin/pages.js ${id}&&npm run build`)).then(() => pid.ins())
|
.then(() => pid = new process(`cd ${path}&&npm run apps&&node bin/pages.js ${id}&&npm run build`), () => sendMessage({code: 0, progress: ++progress}))
|
||||||
|
.then(() => pid.ins())
|
||||||
.then(() => fse.emptyDir(dist))
|
.then(() => fse.emptyDir(dist))
|
||||||
.then(() => sendMessage({code: 0, progress: 70}))
|
.then(() => progress = 70, sendMessage({code: 0, progress}))
|
||||||
.then(() => pid = new process(`./shell/move.sh ${info.type} ${path} ${dist}`)).then(() => pid.ins())
|
.then(() => pid = new process(`./shell/move.sh ${info.type} ${path} ${dist}`), () => sendMessage({code: 0, progress: ++progress})).then(() => pid.ins())
|
||||||
.then(() => sendMessage({code: 0, progress: 90}))
|
.then(() => progress = 90, sendMessage({code: 0, progress}))
|
||||||
.then(() => db.query(`update node_custom_config set download='${dayjs().format("YYYY-MM-DD HH:mm:ss")}',error='' where ${uniCon}`))
|
.then(() => db.query(`update node_custom_config set download='${dayjs().format("YYYY-MM-DD HH:mm:ss")}',error='' where ${uniCon}`))
|
||||||
.then(() => db.detail({table: "node_custom_config", id}))
|
.then(() => db.detail({table: "node_custom_config", id}))
|
||||||
.then(row => sendMessage({code: 0, progress: 100, row}))
|
.then(row => sendMessage({code: 0, progress: 100, row}))
|
||||||
|
|||||||
Reference in New Issue
Block a user