32 lines
951 B
JavaScript
32 lines
951 B
JavaScript
/**
|
|
* @author Taoya
|
|
* @date 2022/5/23
|
|
* @Description: 构建开发环境包
|
|
*/
|
|
const fs = require('fs')
|
|
const { resolve } = require('path')
|
|
var child_process = require('child_process')
|
|
const chalk = require('chalk');
|
|
const logger = require('./utils/logger.js');
|
|
|
|
|
|
function main() {
|
|
let baseDir = resolve('./');
|
|
let packageName = 'dev.apk';
|
|
let revRun = child_process.exec('npx cordova run android', function (e, res) {
|
|
if(res.indexOf('BUILD SUCCESSFUL')!=-1){
|
|
logger.log('info', '构建成功')
|
|
if(fs.existsSync(`./dist/${packageName}`)) {
|
|
fs.unlinkSync(`./dist/${packageName}`)
|
|
}
|
|
fs.renameSync('./platforms/android/app/build/outputs/apk/debug/app-debug.apk', './dist/dev.apk')
|
|
}else{
|
|
logger.log('info', '构建失败')
|
|
}
|
|
});
|
|
revRun.stdout.on('data', function (data) {
|
|
console.log(chalk.green(data));
|
|
})
|
|
}
|
|
main();
|