forked from opentiny/tiny-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeleteDist.js
33 lines (29 loc) · 1.02 KB
/
deleteDist.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const path = require('path')
const fs = require('fs-extra')
const ROOTPATH = path.join(__dirname, './')
const publish = () => {
const publishDir = path.join(ROOTPATH, 'packages')
fs.readdirSync(publishDir).forEach((item) => {
const childPath = path.join(publishDir, item)
const stat = fs.statSync(childPath)
if (stat.isDirectory()) {
const distPath = path.join(childPath, './dist')
if (fs.existsSync(distPath) && fs.statSync(distPath).isDirectory()) {
fs.removeSync(distPath)
}
if (item.startsWith('chart')) {
fs.readdirSync(childPath).forEach((value) => {
const chartChildPath = path.join(childPath, value)
const chartStat = fs.statSync(chartChildPath)
if (value.includes('-') && chartStat.isDirectory()) {
const distPath = path.join(chartChildPath, './dist')
fs.existsSync(distPath) &&
fs.statSync(distPath).isDirectory() &&
fs.removeSync(distPath)
}
})
}
}
})
}
publish()