优化打包方法
This commit is contained in:
28
src/tools/childProcess.js
Normal file
28
src/tools/childProcess.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const {exec} = require("child_process");
|
||||
|
||||
class Process {
|
||||
constructor(cmd) {
|
||||
this.cmd = cmd
|
||||
this.pid = exec(cmd, {windowsHide: true, encoding: "utf8"});
|
||||
}
|
||||
|
||||
static new(cmd) {
|
||||
return new Promise((resolve, reject) => exec(cmd, {windowsHide: true}, (err) => {
|
||||
if (!err) {
|
||||
resolve()
|
||||
} else reject(err)
|
||||
}))
|
||||
}
|
||||
|
||||
ins() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.pid.on('close', (code, err) => {
|
||||
if (code == 0 && !err) {
|
||||
resolve()
|
||||
} else reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Process
|
||||
Reference in New Issue
Block a user