generated from Aliucord/plugin-template-rn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.mjs
37 lines (32 loc) · 957 Bytes
/
build.mjs
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
import { spawnSync } from "child_process";
import { platform } from "process";
import { existsSync } from "fs";
import { join } from "path";
import { argv, cwd, exit } from "process";
function check(bool, message) {
if (!bool) {
console.error(message);
exit(1);
}
}
let watch;
let plugin = argv[2];
if (plugin === "--watch") {
watch = true;
plugin = argv[3];
}
check(!!plugin, `Usage: ${argv.join(" ")} <PLUGIN>`);
const files = ["index.ts", "index.tsx"];
const file = files.find(file => existsSync(join(plugin, file)));
const path = join(plugin, file);
check(existsSync(path), `No such file: ${path}`);
const proc = spawnSync((platform === "win32") ? ".\\node_modules\\.bin\\rollup.cmd" : "node_modules/.bin/rollup", ["-c", "--configPlugin", "typescript", watch && "--watch"].filter(Boolean), {
stdio: "inherit",
cwd: cwd(),
env: {
plugin
}
});
if (proc.error) {
console.error(proc.error)
}