diff options
| author | Soccera1 <[email protected]> | 2026-08-06 01:58:10 +1000 |
|---|---|---|
| committer | Soccera1 <[email protected]> | 2026-08-06 02:00:12 +1000 |
| commit | d11632d44b740ab8b78ec27544afb480f406a9d5 (patch) | |
| tree | 7b56ee4e54a7858c01e1c8b4a74832e9db8eaa09 /scripts/build.js | |
| parent | 471a0af4628e4796421fdba55ebc79bb4240c47e (diff) | |
| download | bnu-d11632d44b740ab8b78ec27544afb480f406a9d5.tar.gz bnu-d11632d44b740ab8b78ec27544afb480f406a9d5.zip | |
Automatically publish to npm
Diffstat (limited to 'scripts/build.js')
| -rw-r--r-- | scripts/build.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/build.js b/scripts/build.js new file mode 100644 index 0000000..8adcc3c --- /dev/null +++ b/scripts/build.js @@ -0,0 +1,46 @@ +import { readdir, rm } from "node:fs/promises"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; + +const root = dirname(dirname(fileURLToPath(import.meta.url))); +const dist = join(root, "dist"); +const commandsSource = join(root, "src/commands"); + +await rm(dist, { recursive: true, force: true }); + +const commandEntrypoints = (await readdir(commandsSource)) + .filter((name) => name.endsWith(".js")) + .map((name) => join(commandsSource, name)); + +const commonOptions = { + target: "bun", + minify: true, + sourcemap: "none", +}; + +const npmLauncher = await Bun.build({ + entrypoints: [join(root, "bin/npm.js")], + outdir: join(dist, "bin"), + target: "node", + minify: true, + sourcemap: "none", +}); + +const runtimeLauncher = await Bun.build({ + ...commonOptions, + entrypoints: [join(root, "bin/bnu.js")], + outdir: join(dist, "runtime"), +}); + +const commands = await Bun.build({ + ...commonOptions, + entrypoints: commandEntrypoints, + outdir: join(dist, "commands"), + root: commandsSource, + splitting: false, +}); + +if (!npmLauncher.success || !runtimeLauncher.success || !commands.success) { + for (const log of [...npmLauncher.logs, ...runtimeLauncher.logs, ...commands.logs]) console.error(log); + process.exit(1); +} |
