Browse Source

Merge branch 'master' of http://192.168.0.115:3000/bill/potree-sdk

xzw 3 years ago
parent
commit
aacbbbc1a0
2 changed files with 24 additions and 15 deletions
  1. 22 13
      main.js
  2. 2 2
      package.json

+ 22 - 13
main.js

@@ -2,23 +2,32 @@ 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
+			`)
+			console.log('发布成功')
+		} catch {
+			console.error('自动发布失败,请手动上传')
+		}
 	}
-})
+}
 
-exec(`yarn build-c`);
+runBuild()

+ 2 - 2
package.json

@@ -18,8 +18,8 @@
   "main": "./build/potree/potree.js",
   "scripts": {
     "start": "gulp watch -c development",
-    "build-c": "node main.js",
-    "build": "gulp build pack -c production",
+    "build": "node main.js",
+    "build-c": "gulp build pack -c production",
     "postinstall": "npm run build"
   },
   "dependencies": {