feat: 打包加固调整

This commit is contained in:
duanshuwen
2025-11-23 18:21:28 +08:00
parent 0b1e7a6679
commit 7eb2a13efe
7 changed files with 99 additions and 129 deletions

View File

@@ -1,21 +1,23 @@
const fs = require('fs')
const { execSync } = require('child_process')
const fs = require('fs-extra')
const path = require('path')
function cleanDirectory(dirPath) {
const resolvedPath = path.resolve(dirPath)
function cleanOutRoot() {
const outDir = path.resolve(process.cwd(), 'out')
const parentDir = path.basename(path.dirname(resolvedPath))
if (parentDir !== 'out') {
console.error(`Error: Directory "${resolvedPath}" is not inside a "out" folder`)
if (!fs.pathExistsSync(outDir)) {
return
}
const distPath = path.join(resolvedPath, 'dist')
if (fs.existsSync(distPath)) {
fs.rmSync(distPath, { recursive: true, force: true })
console.log(`deleted: ${distPath}`)
fs.removeSync(outDir)
if (fs.pathExistsSync(outDir)) {
execSync(`cmd /c rd /s /q "${outDir}"`, { stdio: 'ignore' })
process.exitCode = 1
}
}
cleanDirectory(process.cwd())
cleanOutRoot()