forked from yan5xu/ququ
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanup.js
More file actions
67 lines (56 loc) · 1.54 KB
/
cleanup.js
File metadata and controls
67 lines (56 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const fs = require('fs');
const path = require('path');
console.log('🧹 清理蛐蛐项目...');
// 需要清理的目录和文件
const cleanupTargets = [
'src/dist',
'dist',
'node_modules/.cache',
'cache',
'*.log',
'funasr_bridge.log'
];
// 递归删除目录
function removeDir(dirPath) {
if (fs.existsSync(dirPath)) {
fs.rmSync(dirPath, { recursive: true, force: true });
console.log(`🗑️ 删除目录: ${dirPath}`);
}
}
// 删除文件
function removeFile(filePath) {
if (fs.existsSync(filePath)) {
fs.unlinkSync(filePath);
console.log(`🗑️ 删除文件: ${filePath}`);
}
}
// 清理构建产物
const distPath = path.join(__dirname, 'src', 'dist');
const buildPath = path.join(__dirname, 'dist');
removeDir(distPath);
removeDir(buildPath);
// 清理缓存
const cachePath = path.join(__dirname, 'cache');
const nodeModulesCachePath = path.join(__dirname, 'node_modules', '.cache');
removeDir(cachePath);
removeDir(nodeModulesCachePath);
// 清理日志文件
const logFiles = [
path.join(__dirname, 'funasr_bridge.log'),
path.join(__dirname, 'electron.log'),
path.join(__dirname, 'main.log')
];
logFiles.forEach(logFile => {
removeFile(logFile);
});
// 清理临时文件
const tempFiles = fs.readdirSync(__dirname).filter(file =>
file.endsWith('.tmp') ||
file.endsWith('.temp') ||
file.startsWith('temp_')
);
tempFiles.forEach(tempFile => {
removeFile(path.join(__dirname, tempFile));
});
console.log('✅ 清理完成!');
console.log('💡 提示: 运行 pnpm install 重新安装依赖');