🎨 Fix the bug of download icon
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
import chalk from 'chalk';
|
||||
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'];
|
||||
|
||||
cliChildProcess = spawn(command, cliCmdArgs, { detached: true });
|
||||
|
||||
cliChildProcess.stdout.on('data', (data) => {
|
||||
console.log(chalk.green(data.toString()));
|
||||
});
|
||||
|
||||
cliChildProcess.stderr.on('data', (data) => {
|
||||
console.error(chalk.yellow(data.toString()));
|
||||
});
|
||||
|
||||
cliChildProcess.on('close', async (code) => {
|
||||
console.log(chalk.yellow(`cli running end with code: ${code}`));
|
||||
if (devHasStarted) return;
|
||||
devHasStarted = true;
|
||||
devChildProcess = await exec('npm run tauri dev -- --config ./src-tauri/.pake/tauri.conf.json --features cli-build');
|
||||
|
||||
devChildProcess.stdout.on('data', (data) => {
|
||||
console.log(chalk.green(data.toString()));
|
||||
});
|
||||
|
||||
devChildProcess.stderr.on('data', (data) => {
|
||||
console.error(chalk.yellow(data.toString()));
|
||||
});
|
||||
|
||||
devChildProcess.on('close', (code) => {
|
||||
console.log(chalk.yellow(`dev running end: ${code}`));
|
||||
process.exit(code);
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
51
rollup.config.js
vendored
51
rollup.config.js
vendored
@@ -5,8 +5,8 @@ import alias from '@rollup/plugin-alias';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import json from '@rollup/plugin-json';
|
||||
import replace from '@rollup/plugin-replace';
|
||||
|
||||
import pakeCliDevPlugin from './plugins/pakeCliDevPlugin.js';
|
||||
import chalk from 'chalk';
|
||||
import { spawn, exec } from 'child_process';
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
const devPlugins = !isProduction ? [pakeCliDevPlugin()] : [];
|
||||
@@ -39,3 +39,50 @@ export default {
|
||||
...devPlugins,
|
||||
],
|
||||
};
|
||||
|
||||
function pakeCliDevPlugin() {
|
||||
let devChildProcess;
|
||||
let cliChildProcess;
|
||||
|
||||
let devHasStarted = false;
|
||||
|
||||
return {
|
||||
name: 'pake-cli-dev-plugin',
|
||||
buildEnd() {
|
||||
const command = 'node';
|
||||
const cliCmdArgs = ['./dist/dev.js'];
|
||||
|
||||
cliChildProcess = spawn(command, cliCmdArgs, { detached: true });
|
||||
|
||||
cliChildProcess.stdout.on('data', data => {
|
||||
console.log(chalk.green(data.toString()));
|
||||
});
|
||||
|
||||
cliChildProcess.stderr.on('data', data => {
|
||||
console.error(chalk.yellow(data.toString()));
|
||||
});
|
||||
|
||||
cliChildProcess.on('close', async code => {
|
||||
console.log(chalk.yellow(`cli running end with code: ${code}`));
|
||||
if (devHasStarted) return;
|
||||
devHasStarted = true;
|
||||
devChildProcess = await exec(
|
||||
'npm run tauri dev -- --config ./src-tauri/.pake/tauri.conf.json --features cli-build',
|
||||
);
|
||||
|
||||
devChildProcess.stdout.on('data', data => {
|
||||
console.log(chalk.green(data.toString()));
|
||||
});
|
||||
|
||||
devChildProcess.stderr.on('data', data => {
|
||||
console.error(chalk.yellow(data.toString()));
|
||||
});
|
||||
|
||||
devChildProcess.on('close', code => {
|
||||
console.log(chalk.yellow(`dev running end: ${code}`));
|
||||
process.exit(code);
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
16
script/build_with_pake_cli.js
vendored
16
script/build_with_pake_cli.js
vendored
@@ -45,15 +45,19 @@ if (process.env.ICON && process.env.ICON !== '') {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
axios
|
||||
.get(process.env.ICON, { responseType: 'arraybuffer' })
|
||||
.then(response => {
|
||||
const downloadIcon = async () => {
|
||||
try {
|
||||
const response = await axios.get(process.env.ICON, { responseType: 'arraybuffer' });
|
||||
console.log('>>>>>>> download icon response:', response);
|
||||
fs.writeFileSync(iconFile, response.data);
|
||||
console.log('>>>>>>> download icon is:', iconFile);
|
||||
params = `${params} --icon ${iconFile}`;
|
||||
})
|
||||
.catch(error => {
|
||||
} catch (error) {
|
||||
console.error('Error occurred during icon download: ', error);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
downloadIcon();
|
||||
} else {
|
||||
console.log("Won't download the icon as ICON environment variable is not defined!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user