Skip to content

Commit

Permalink
chore(elog): 0.9.1-beta.1
Browse files Browse the repository at this point in the history
1.rimraf删除优化
  • Loading branch information
LetTTGACO committed Nov 2, 2023
1 parent 6304b5a commit a5cbfee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 5 additions & 4 deletions packages/cli/src/scripts/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ const clean = async (customConfigPath: string, customCachePath: string) => {
cleanCache(cacheFilePath)
// 清楚本地图片
if (enable && imagePlatform === 'local' && imageOutputDir) {
cleanImages(imageOutputDir)
}
if (deployPlatform === 'local' && docOutputDir) {
cleanPost(docOutputDir)
cleanImages(imageOutputDir, () => {
if (deployPlatform === 'local' && docOutputDir) {
cleanPost(docOutputDir)
}
})
}
} catch (error: any) {
out.err(`清理失败, ${error.message}`)
Expand Down
10 changes: 7 additions & 3 deletions packages/cli/src/utils/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ export const cleanPost = (postPath: string) => {
rimraf(dist, (error) => {
if (error) {
out.err(`清理文档失败: ${error.message}`)
} else {
out.info('清理文档: ' + dist)
}
out.info('清理文档: ' + dist)
})
} catch (error: any) {
out.err(`清理文档失败: ${error.message}`)
Expand All @@ -38,16 +39,19 @@ export const cleanCache = (cachePath: string) => {
/**
* 清理本地图片
*/
export const cleanImages = (imgsPath: string) => {
export const cleanImages = (imgsPath: string, callback: () => void) => {
try {
const dist = path.join(__cwd, imgsPath)
rimraf(dist, (error) => {
if (error) {
out.err(`清理图片失败: ${error.message}`)
} else {
out.info('清理图片: ' + dist)
}
out.info('清理图片: ' + dist)
callback()
})
} catch (error: any) {
out.err(`清理图片失败: ${error.message}`)
callback()
}
}

0 comments on commit a5cbfee

Please sign in to comment.