forked from Aliucord/plugin-template-rn
-
Notifications
You must be signed in to change notification settings - Fork 1
/
buildAll.mjs
38 lines (35 loc) · 1.32 KB
/
buildAll.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
38
import { spawnSync } from "child_process";
import { platform } from "process";
import { existsSync } from "fs";
import { join } from "path";
import { cwd } from "process";
import { readdir } from "fs"
readdir(cwd(), { withFileTypes: true }, (err, folders) => {
folders.forEach(folder => {
if(!folder.isDirectory()) return;
const folderName = folder.name;
const manifestPath = join(folderName, "manifest.json")
if(existsSync(manifestPath))
{
let path = null
if (existsSync(join(folderName, "index.ts"))) path = join(folderName, "index.ts")
else if (existsSync(join(folderName, "index.tsx"))) path = join(folderName, "index.tsx")
if(!existsSync(path))
{
console.log(`Skipping ${folderName}`)
return;
}
const proc = spawnSync((platform === "win32") ? ".\\node_modules\\.bin\\rollup.cmd" : "node_modules/.bin/rollup", ["-c", "--configPlugin", "typescript"].filter(Boolean), {
stdio: "inherit",
cwd: cwd(),
env: {
plugin: folderName,
pluginPath: path
}
});
if (proc.error) {
console.error(proc.error)
}
}
})
})