-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.js
More file actions
28 lines (26 loc) · 710 Bytes
/
deploy.js
File metadata and controls
28 lines (26 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* eslint-disable @typescript-eslint/no-var-requires */
const OSS = require("ali-oss");
const fs = require("fs");
const readDir = (path) => {
let arr = [];
let temp = fs.readdirSync(path);
temp.forEach((v) => {
if (fs.statSync(path + "/" + v).isDirectory()) {
arr.push(...readDir(path + "/" + v));
} else {
arr.push(path + "/" + v);
}
});
return arr;
};
let client = new OSS({
region: "oss-cn-hongkong",
accessKeyId: process.env.ACCESSKEYID,
accessKeySecret: process.env.ACCESSKEYSECRET,
});
client.useBucket("jyb-site");
readDir("./dist").forEach((file) => {
client.put(file.split("./dist/")[1], file).then(() => {
console.log("上传成功:", file);
});
});