31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
import { spawn } from "node:child_process";
|
|
import { existsSync } from "node:fs";
|
|
import { mkdir, copyFile } from "node:fs/promises";
|
|
const windows = process.platform === "win32";
|
|
const command = windows ? "gradlew.bat" : "sh";
|
|
const targets = process.argv.slice(2);
|
|
if (!targets.length) targets.push(":plugin:build", ":fabric:build");
|
|
await new Promise((resolve, reject) => {
|
|
const child = spawn(command, windows ? targets : ["./gradlew", ...targets], {
|
|
cwd: "minecraft",
|
|
stdio: "inherit",
|
|
shell: windows,
|
|
});
|
|
child.on("error", reject);
|
|
child.on("exit", (code) =>
|
|
code === 0 ? resolve() : reject(new Error(`Gradle exited ${code}`)),
|
|
);
|
|
});
|
|
for (const name of ["plugin", "fabric"]) {
|
|
const directory = `public/tools/${name === "fabric" ? "mod" : "plugin"}`;
|
|
const file = `minegeo-${name}-1.21.11.jar`,
|
|
path = `minecraft/${name}/build/libs/${file}`;
|
|
if (existsSync(path)) {
|
|
await mkdir(directory, { recursive: true });
|
|
await copyFile(path, `${directory}/${file}`);
|
|
console.log(
|
|
`Updated ${directory}/${file}. Include this JAR in your next commit.`,
|
|
);
|
|
}
|
|
}
|