niucloud/admin/scripts/clean-core.cjs
wangchen14709853322 3e71008192 v2.0-beta-20260626
v2框架公测版测试流程请看v2.0-beta.md
2026-06-26 17:56:38 +08:00

26 lines
785 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 删除 dist/.corecore 构建 staging
*
* build:core 在 vite build 前执行,避免 Windows 上旧 chunk 残留导致 hash 不一致。
* 使用 rename → 再删 的策略,降低文件被占用时 rmSync 失败的概率。
*/
const fs = require('fs')
const path = require('path')
const core = path.join(__dirname, '..', 'dist', '.core')
function rmDir(dir) {
if (!fs.existsSync(dir)) return
const trash = `${dir}.__trash_${Date.now()}`
try {
fs.renameSync(dir, trash)
} catch {
fs.rmSync(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 })
return
}
fs.rmSync(trash, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 })
}
rmDir(core)
console.log('[clean-core] removed dist/.core')