// ============================================================
// 清理所有构建产物
//   npm run build:clean
// ============================================================

import { rmSync, existsSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = join(__dirname, '..', '..');

const dirs = ['release', 'dist', 'dist-electron'];

for (const dir of dirs) {
  const p = join(ROOT, dir);
  if (existsSync(p)) {
    rmSync(p, { recursive: true, force: true });
    console.log(`已清理: ${dir}/`);
  } else {
    console.log(`跳过（不存在）: ${dir}/`);
  }
}

console.log('\n清理完成。');
