Files
torlink/scripts/postbuild.cjs
T
yaninniandGitHub 17a06fa37a fix: make postbuild cross-platform so the CLI builds on Windows (#18)
The postbuild step was using cp and chmod, which only work on Unix. On Windows npm run build would run tsup successfully but then fail at the cp command, leaving dist/cli.cjs missing. Since the package.json bin field points there, npx torlnk would just say the command isn't recognized.I replaced the shell one-liner with scripts/postbuild.mjs

Small Node script that copies cli-entry.cjs to dist/cli.cjs and marks it executable. chmod is a no-op on Windows but still does the right thing for the published package, so the output is identical across Windows, macOS, and Linux.
2026-06-30 16:35:01 -04:00

21 lines
647 B
JavaScript

'use strict';
const { chmodSync, copyFileSync } = require('node:fs');
const { resolve } = require('node:path');
const root = resolve(__dirname, '..');
const src = resolve(root, 'scripts/cli-entry.cjs');
const dest = resolve(root, 'dist/cli.cjs');
copyFileSync(src, dest);
// On Windows chmod is effectively a no-op, and npm re-applies bin permissions on install anyway, so a failure
// here shouldn't fail the build, but warn rather than swallow the error.
try {
chmodSync(dest, 0o755);
} catch (err) {
console.warn('postbuild: could not set executable bit on dist/cli.cjs:', err.message);
}
console.log('postbuild: wrote dist/cli.cjs');