-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbuild.mjs
More file actions
39 lines (33 loc) · 1.22 KB
/
build.mjs
File metadata and controls
39 lines (33 loc) · 1.22 KB
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
import { build } from "vite";
import { join as joinPath } from "path";
import { clone as gitClone } from "isomorphic-git";
import * as http from "isomorphic-git/http/node";
import * as fs from "fs";
const parseArgv = (argv) => {
const result = {};
for (let i = 0; i < argv.length; i++) {
const arg = argv[i];
if (arg.startsWith('--')) {
const [name, value] = arg.slice(2).split('=');
result[name] = value || true;
};
};
return result;
};
const argv = parseArgv(process.argv);
await build();
if (argv.bundleChannels === true) {
const dir = joinPath(process.cwd(), "dist", "channels"),
channelsBundleURL = argv.channelsURL ?? "https://github.com/ZapprTV/channels.git";
if (channelsBundleURL.endsWith(".git")) {
await gitClone({
fs, http, dir, url: channelsBundleURL
});
await fs.promises.rm(joinPath(dir, ".git"), { recursive: true, force: true }, err => {
if (err) throw err;
});
} else {
await fs.promises.cp(joinPath(process.cwd(), channelsBundleURL), joinPath(process.cwd(), "dist", channelsBundleURL), { recursive: true });
};
console.log("download dei channels terminato");
};