feat: 打包加固调整
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user