cordova-11/cmd/dev.js

32 lines
951 B
JavaScript
Raw Normal View History

2022-05-24 14:49:24 +08:00
/**
* @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();