Pārlūkot izejas kodu

更新 'UpdateGitRep.js'

NiceTry12138 5 mēneši atpakaļ
vecāks
revīzija
bc4c105d6b
1 mainītis faili ar 14 papildinājumiem un 4 dzēšanām
  1. 14 4
      UpdateGitRep.js

+ 14 - 4
UpdateGitRep.js

@@ -21,8 +21,16 @@ const dirNameBlackList = [
     "ThirdParty",
 ]
 
+class RepItem
+{
+    constructor(inPath, inUrl) {
+        this.path = inPath; // 仓库名称
+        this.url = inUrl; // 仓库地址
+    }
+}
+
 class RepUrls{
-    repUrls = [];
+    RepItems = [];
 }
 
 // 拉取 Git 仓库最新代码到指定路径
@@ -150,19 +158,21 @@ function cloneRep()
     let inputRepURLJsonFile = path.join(rootPath, InputRepURLJsonName);
     if(!fs.existsSync(inputRepURLJsonFile)) {
         let temp = new RepUrls();
-        temp.repUrls = ["https://xxx.com/test/url.git"];
+        temp.RepItems = [new RepItem("cpp", "https://xxx.com/test/url.git")];
         fs.writeFileSync(inputRepURLJsonFile, JSON.stringify(temp, null, 4), "utf-8");
         console.error(`找不到 ${InputRepURLJsonName} 文件,已生成该文件,请填充内容`);
         return;
     }
     let repUrls = JSON.parse(fs.readFileSync(inputRepURLJsonFile, "utf-8"));
-    repUrls.repUrls.forEach((url) => {
+    repUrls.RepItems.forEach((item) => {
+        let url = item.url;
+        let relativePath = item.path;
         if(!url || url.trim() === "") {
             console.error(`无效的 Git 仓库 URL: ${url}`);
             return;
         }
 
-        let locationPath = path.join(rootPath, PluginDirName);
+        let locationPath = path.join(rootPath, PluginDirName, relativePath);
         let localPath = path.join(locationPath, path.basename(url, ".git"));
         pullGitRepository(url, localPath);
     });