fix: fix some child_process problems
This commit is contained in:
@@ -4,13 +4,19 @@ import {spawn, exec} from 'child_process';
|
||||
|
||||
// just run in development mode
|
||||
export default function pakeCliDevPlugin() {
|
||||
let devChildProcess;
|
||||
let cliChildProcess;
|
||||
|
||||
let devHasStarted = false;
|
||||
|
||||
return {
|
||||
name: 'pake-cli-dev-plugin',
|
||||
buildEnd() {
|
||||
|
||||
const command = 'node';
|
||||
const cliCmdArgs = ['./dist/dev.js'];
|
||||
const cliChildProcess = spawn(command, cliCmdArgs);
|
||||
|
||||
cliChildProcess = spawn(command, cliCmdArgs, {detached: true});
|
||||
|
||||
cliChildProcess.stdout.on('data', (data) => {
|
||||
console.log(chalk.green(data.toString()));
|
||||
@@ -22,20 +28,25 @@ export default function pakeCliDevPlugin() {
|
||||
|
||||
cliChildProcess.on('close', async (code) => {
|
||||
console.log(chalk.yellow(`cli running end with code: ${code}`));
|
||||
cliChildProcess.kill();
|
||||
const dev = await exec('npm run tauri dev -- --config ./src-tauri/.pake/tauri.conf.json --features cli-build');
|
||||
if (devHasStarted) return;
|
||||
devHasStarted = true;
|
||||
|
||||
dev.stdout.on('data', (data) => {
|
||||
console.error(chalk.green(data.toString()));
|
||||
const devCommand = 'npm';
|
||||
const devArgs = ['run', 'tauri', 'dev', '--', '--config', './src-tauri/.pake/tauri.conf.json', '--features', 'cli-build'];
|
||||
devChildProcess = spawn(devCommand, devArgs, {detached: true});
|
||||
|
||||
|
||||
devChildProcess.stdout.on('data', (data) => {
|
||||
console.log(chalk.green(data.toString()));
|
||||
});
|
||||
|
||||
dev.stderr.on('data', (data) => {
|
||||
devChildProcess.stderr.on('data', (data) => {
|
||||
console.error(chalk.yellow(data.toString()));
|
||||
});
|
||||
|
||||
dev.on('close', () => {
|
||||
dev.kill();
|
||||
console.log(chalk.green('rebuild start'));
|
||||
devChildProcess.on('close', (code) => {
|
||||
console.log(chalk.yellow(`dev running end: ${code}`));
|
||||
process.exit(code);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user