mirror of
https://github.com/baairon/torlink.git
synced 2026-07-08 18:28:22 +02:00
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.
21 lines
647 B
JavaScript
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');
|