ci.preview 执行完毕,通过 process.exitCode = 0,无法平稳退出,需要执行 process.exit(0) 来强制退出,但是这样有风险,可能导致未完成的异步任务挂起
const ci = require('miniprogram-ci')
;(async () => {
const project = new ci.Project({
appid: 'wxsomeappid',
type: 'miniProgram',
projectPath: 'the/project/path',
privateKeyPath: 'the/path/to/privatekey',
ignores: ['node_modules/**/*'],
})
const previewResult = await ci.preview({
project,
desc: 'hello',
setting: {
es6: true,
},
qrcodeFormat: 'image',
qrcodeOutputDest: '/path/to/qrcode/file/destination.jpg',
onProgressUpdate: console.log,
// pagePath: 'pages/index/index', // 预览页面
// searchQuery: 'a=1&b=2', // 预览参数 [注意!]这里的`&`字符在命令行中应写成转义字符`\&`
// scene: 1011, // 场景值
})
console.log(previewResult)
process.exitCode = 0; // 这里无法退出,说明 ci.preview 即使输出 previewResult 里,它里面依旧在运行着什么东西
// process.exit(0); // 只有通过 process.exit 才能强制退出,但是这样做有风险
})()
相关问题
[小程序 发布工具 miniprogram-ci 上传完成后怎么退出node执行?]
https://developers.weixin.qq.com/community/develop/doc/000a8a38a98400b0685ac152a56800?highLine=miniprogram-ci%2520%25E6%2589%25A7%25E8%25A1%258Cci.preview%25E5%25AE%258C%25E6%25AF%2595%25E5%2590%258E%25EF%25BC%258Cnode%25E8%25BF%259B%25E7%25A8%258B%25E4%25BE%259D%25E6%2597%25A7%25E6%2597%25A0%25E6%25B3%2595%25E9%2580%2580%25E5%2587%25BA