/
upload.js
47 lines (40 loc) · 1017 Bytes
/
upload.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { resolve } from "path"
import minimist from "minimist"
import fs from "fs"
import upload from "../index.js"
const args = minimist(process.argv.slice(2))
const buildMode = args.mode
const cosMap = {}
const COS_BASE = "camin/"
const cwd = resolve("demo/dist")
// h5-static-cos.json 里是资源上传的 COS 的参数,使用该插件时需自行替换成自己 COS 的参数
const cosFile = resolve("./h5-static-cos.json")
if (fs.existsSync(cosFile)) {
try {
const datas = JSON.parse(fs.readFileSync(cosFile, "utf8"))
Object.assign(
cosMap,
datas.cosMap[buildMode],
{
SecretId: datas.SecretId,
SecretKey: datas.SecretKey,
}
)
// eslint-disable-next-line no-empty
} catch (err) {}
}
upload({
cosBase: `${COS_BASE}console/assets/1.2.0/`,
cwd,
...cosMap,
}).then(() => {
console.log("----finish 1")
})
upload({
cosBase: `${COS_BASE}console/`,
cwd,
files: ["index.html"],
...cosMap,
}).then(() => {
console.log("----finish 2")
})