liyongli 2 年之前
父節點
當前提交
74ab7a4a55
共有 1 個文件被更改,包括 19 次插入13 次删除
  1. 19 13
      saveOSSAGitte.js

+ 19 - 13
saveOSSAGitte.js

@@ -2,7 +2,7 @@
 const path = require("path");
 const fs = require("fs");
 const oss = require("ali-oss");
-const {execSync } = require("child_process");
+const { execSync } = require("child_process");
 
 (async function Init() {
   const localDir = "dist/";
@@ -51,7 +51,7 @@ const {execSync } = require("child_process");
         }
       })
     );
-    console.log("oss文件清除完成");
+    console.log("oss文件清除---完成");
   }
 
   /**
@@ -64,7 +64,7 @@ const {execSync } = require("child_process");
       // 如果本地文件的完整路径中未指定本地路径,则默认从示例程序所属项目对应本地路径中上传文件。
       let dir = filePath[0].split("\\");
       dir = dir.reverse()[0] + "/";
-      if(dir === localDir) dir = "";
+      if (dir === localDir) dir = "";
       await client.put(
         baseOssDir + dir + filePath[1],
         path.normalize(filePath.join("\\"))
@@ -80,18 +80,24 @@ const {execSync } = require("child_process");
   /**
    * 上传git
    */
-  function execFun(){
-    try{
-       execSync('git add .');
-       execSync('git commit -m "提交"');
-       execSync('git push');
-    }catch(e){
-        console.error(e);
+  function execFun() {
+    try {
+      execSync("git add .");
+      execSync('git commit -m "提交"');
+      execSync("git push");
+      console.log("上传git---完成");
+    } catch (e) {
+      console.log("上传git---失败");
+      console.error(e);
     }
   }
-  
+
   execFun();
   await delDir(baseOssDir);
-  await getFiles(dirPath);
-  console.log("数据上传oss完成");
+  try {
+    await getFiles(dirPath);
+    console.log("数据上传oss---完成");
+  } catch (err) {
+    console.log("数据上传oss---失败");
+  }
 })();