create-hackhub-mod 0.3.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
import { build, context } from "esbuild";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
2
4
|
|
|
3
5
|
const isWatch = process.argv.includes("--watch");
|
|
4
6
|
|
|
7
|
+
function copyDirSync(src: string, dest: string) {
|
|
8
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
9
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
10
|
+
const srcPath = path.join(src, entry.name);
|
|
11
|
+
const destPath = path.join(dest, entry.name);
|
|
12
|
+
if (entry.isDirectory()) {
|
|
13
|
+
copyDirSync(srcPath, destPath);
|
|
14
|
+
} else {
|
|
15
|
+
fs.copyFileSync(srcPath, destPath);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function prepareDist() {
|
|
21
|
+
fs.mkdirSync("dist", { recursive: true });
|
|
22
|
+
fs.copyFileSync("manifest.json", path.join("dist", "manifest.json"));
|
|
23
|
+
if (fs.existsSync("assets")) {
|
|
24
|
+
copyDirSync("assets", path.join("dist", "assets"));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
5
28
|
const config = {
|
|
6
29
|
entryPoints: ["src/index.ts"],
|
|
7
30
|
bundle: true,
|
|
8
|
-
outfile: "mod.js",
|
|
31
|
+
outfile: "dist/mod.js",
|
|
9
32
|
format: "cjs" as const,
|
|
10
33
|
platform: "neutral" as const,
|
|
11
34
|
target: "es2020",
|
|
@@ -16,13 +39,15 @@ const config = {
|
|
|
16
39
|
};
|
|
17
40
|
|
|
18
41
|
async function main() {
|
|
42
|
+
prepareDist();
|
|
43
|
+
|
|
19
44
|
if (isWatch) {
|
|
20
45
|
const ctx = await context(config);
|
|
21
46
|
await ctx.watch();
|
|
22
47
|
console.log("Watching for changes...");
|
|
23
48
|
} else {
|
|
24
49
|
await build(config);
|
|
25
|
-
console.log("Build complete: mod.js");
|
|
50
|
+
console.log("Build complete: dist/mod.js");
|
|
26
51
|
}
|
|
27
52
|
}
|
|
28
53
|
|