|
@@ -0,0 +1,48 @@
|
|
|
+// const client = require("ali-oss");
|
|
|
+const path = require("path");
|
|
|
+const fs = require("fs");
|
|
|
+const { execSync } = require("child_process");
|
|
|
+
|
|
|
+(async function Init() {
|
|
|
+ const localDir = "dist/";
|
|
|
+ const dirPath = path.resolve(__dirname, "./" + localDir);
|
|
|
+ const list = []
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取localDir下的所有文件路径
|
|
|
+ * @param {string} pathDir
|
|
|
+ */
|
|
|
+ async function getFiles(pathDir) {
|
|
|
+ const dirList = fs.readdirSync(pathDir) || [];
|
|
|
+ for (let i = 0; i < dirList.length; i++) {
|
|
|
+ const P = [pathDir, dirList[i]];
|
|
|
+ const stat = fs.lstatSync(P.join("\\"));
|
|
|
+ if (!stat.isDirectory()) {
|
|
|
+ list.push(P);
|
|
|
+ } else getFiles(P.join("\\"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上传git
|
|
|
+ */
|
|
|
+ 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();
|
|
|
+ try {
|
|
|
+ await getFiles(dirPath);
|
|
|
+ console.log("获取文件路径---完成", list);
|
|
|
+ } catch (err) {
|
|
|
+ console.log("数据上传oss---失败");
|
|
|
+ }
|
|
|
+})();
|