|
@@ -2,23 +2,31 @@ const util = require('util');
|
|
|
const child_process = require('child_process');
|
|
|
const exec = util.promisify(child_process.exec);
|
|
|
const fs = require('fs-extra')
|
|
|
-const path = require('path')
|
|
|
-
|
|
|
const PATH = `./.laser-lib-path`
|
|
|
+const inInit = fs.existsSync(PATH)
|
|
|
+const initLocal = inInit && fs.readFileSync(PATH).toString()
|
|
|
const buildPaths = [
|
|
|
`build`,
|
|
|
- ...fs.existsSync(PATH) ? [fs.readFileSync(PATH).toString()] : []
|
|
|
+ ...inInit ? [initLocal] : []
|
|
|
]
|
|
|
|
|
|
-buildPaths.forEach(d => {
|
|
|
- const potreeDir = path.resolve(__dirname, d, 'potree')
|
|
|
- const shadersDir = path.resolve(__dirname, d, 'shaders')
|
|
|
- if (fs.existsSync(potreeDir)) {
|
|
|
- fs.emptyDirSync(potreeDir)
|
|
|
- }
|
|
|
- if (fs.existsSync(shadersDir)) {
|
|
|
- fs.emptyDirSync(shadersDir)
|
|
|
+const runBuild = async () => {
|
|
|
+ console.log('正在进行打包')
|
|
|
+ await exec(`yarn build-c`);
|
|
|
+ console.log('打包已完成正在发布到git仓库')
|
|
|
+ if (initLocal) {
|
|
|
+ try {
|
|
|
+ await exec(`
|
|
|
+ cd ${initLocal}
|
|
|
+ git pull
|
|
|
+ git add -A
|
|
|
+ git commit -m 'fix: 更新sdk'
|
|
|
+ git push
|
|
|
+ `)
|
|
|
+ } catch {
|
|
|
+ console.error('自动打包失败,请手动上传')
|
|
|
+ }
|
|
|
}
|
|
|
-})
|
|
|
+}
|
|
|
|
|
|
-exec(`yarn build-c`);
|
|
|
+runBuild()
|