forked from opentiny/tiny-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnpm-publish.js
41 lines (37 loc) · 1.22 KB
/
npm-publish.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
34
35
36
37
38
39
40
41
const { execSync } = require('child_process')
const path = require('path')
const fs = require('fs-extra')
const utils = require('./build/utils')
const ROOTPATH = path.join(__dirname, './')
const publish = () => {
const publishDir = path.join(ROOTPATH, 'dist')
fs.readdirSync(publishDir).forEach((item) => {
const childPath = path.join(publishDir, item)
const stat = fs.statSync(childPath)
if (stat.isDirectory()) {
const cmd = `npm publish ./dist/${item} --access public`
try {
execSync(cmd, { cwd: ROOTPATH })
} catch (error) {
utils.logYellow(error)
execSync(cmd, { cwd: ROOTPATH })
}
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 cmd = `npm publish ./dist/chart/${value} --access public`
try {
execSync(cmd, { cwd: ROOTPATH })
} catch (error) {
utils.logYellow(error)
execSync(cmd, { cwd: ROOTPATH })
}
}
})
}
}
})
}
publish()