import { chmod, rm } from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { build } from "esbuild"; const harnessRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); await rm(path.join(harnessRoot, "dist"), { recursive: true, force: true }); const common = { absWorkingDir: harnessRoot, bundle: true, platform: "node", target: "node20", format: "cjs", legalComments: "eof", sourcemap: false, }; await Promise.all([ build({ ...common, entryPoints: [path.join(harnessRoot, "src", "cli.ts")], outfile: path.join(harnessRoot, "dist", "cli.cjs"), banner: { js: "#!/usr/bin/env node" }, }), build({ ...common, entryPoints: [path.join(harnessRoot, "src", "index.ts")], outfile: path.join(harnessRoot, "dist", "index.cjs"), }), ]); await chmod(path.join(harnessRoot, "dist", "cli.cjs"), 0o755);