40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
/**
|
||
* 构建前脚本:关闭正在运行的 asset-pro.exe
|
||
*/
|
||
const { execSync } = require('child_process');
|
||
|
||
try {
|
||
// 在 Windows 上查找并关闭 asset-pro.exe
|
||
if (process.platform === 'win32') {
|
||
try {
|
||
// 查找进程
|
||
const result = execSync('tasklist /FI "IMAGENAME eq asset-pro.exe" /FO CSV', {
|
||
encoding: 'utf-8',
|
||
stdio: 'pipe'
|
||
});
|
||
|
||
if (result.includes('asset-pro.exe')) {
|
||
console.log('检测到正在运行的 asset-pro.exe,正在关闭...');
|
||
// 强制关闭进程
|
||
execSync('taskkill /F /IM asset-pro.exe', {
|
||
stdio: 'pipe'
|
||
});
|
||
console.log('已关闭 asset-pro.exe');
|
||
// 等待一下确保进程完全关闭
|
||
setTimeout(() => {}, 500);
|
||
} else {
|
||
console.log('未检测到正在运行的 asset-pro.exe');
|
||
}
|
||
} catch (error) {
|
||
// 如果 taskkill 失败(进程不存在),忽略错误
|
||
if (!error.message.includes('not found') && !error.message.includes('找不到')) {
|
||
console.log('关闭进程时出错(可能进程不存在):', error.message);
|
||
}
|
||
}
|
||
}
|
||
} catch (error) {
|
||
// 忽略所有错误,继续构建
|
||
console.log('检查进程时出错:', error.message);
|
||
}
|
||
|