mirror of
https://github.com/baairon/torlink.git
synced 2026-07-08 18:28:22 +02:00
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.
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@
|
||||
"scripts": {
|
||||
"dev": "tsx src/index.tsx",
|
||||
"build": "tsup",
|
||||
"postbuild": "cp scripts/cli-entry.cjs dist/cli.cjs && chmod +x dist/cli.cjs",
|
||||
"postbuild": "node scripts/postbuild.cjs",
|
||||
"start": "node dist/index.js",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run",
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
'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');
|
||||
Reference in New Issue
Block a user