Skip to content

Commit 23dc33e

Browse files
committed
fix(alita): 每次转化增加目录的清理工作
1 parent c0b0cec commit 23dc33e

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

examples/HelloWorldExpoWP/xx/ds.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Copyright (c) Areslabs.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
*/
8+

src/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import fse from 'fs-extra'
1111
import struc, {geneWXFileStruc, exitStruc} from './struc/index'
12-
import {isStaticRes, getDependenciesMap, getRNCompList} from './util/util'
12+
import {isStaticRes, getDependenciesMap, getRNCompList, emptyDir} from './util/util'
1313
import packagz from '../package.json'
1414

1515

@@ -83,6 +83,12 @@ const OUT_DIR = path.resolve(options.outdir)
8383
console.log(`输入目录: ${INPUT_DIR}`.info)
8484
console.log(`输出目录: ${OUT_DIR}`.info)
8585

86+
emptyDir(OUT_DIR, new Set([
87+
'miniprogram_npm',
88+
'node_modules'
89+
]))
90+
console.log('输出目录清理完成'.info)
91+
8692
const watchMode = options.watch
8793

8894

src/util/util.js

+19
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,22 @@ export function getRNCompList() {
210210
return `WX${comp}`
211211
})
212212
}
213+
214+
215+
export function emptyDir(dir, ignoreArr) {
216+
const allFiles = fse.readdirSync(dir)
217+
for(let i = 0; i < allFiles.length; i ++) {
218+
const partPath = allFiles[i]
219+
if (ignoreArr.has(partPath)) {
220+
continue
221+
}
222+
223+
const absolutePath = path.resolve(dir, partPath)
224+
225+
if (ignoreArr.has(absolutePath)) {
226+
continue
227+
}
228+
229+
fse.removeSync(absolutePath)
230+
}
231+
}

0 commit comments

Comments
 (0)