const fs = require("node:fs"); const path = require("node:path"); const projectRoot = path.resolve(__dirname, ".."); const cliEntry = path.join(projectRoot, "dist", "cli", "index.js"); const shebang = "#!/usr/bin/env node\n"; if (!fs.existsSync(cliEntry)) { console.log(`dist/cli/index.js not found — skipping shebang check (build may not have run yet)`); process.exit(0); } const content = fs.readFileSync(cliEntry, "utf-8"); if (content.startsWith(shebang.trim())) { console.log("Shebang already present in dist/cli/index.js"); process.exit(0); } const updated = shebang + content; fs.writeFileSync(cliEntry, updated, "utf-8"); console.log("Prepended shebang to dist/cli/index.js"); process.exit(0);