diff --git a/package-lock.json b/package-lock.json index 16ab523..74fe295 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "torlink", + "name": "torlnk", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "torlink", + "name": "torlnk", "version": "1.0.0", "license": "MIT", "dependencies": { @@ -16,7 +16,7 @@ "webtorrent": "^2.4.1" }, "bin": { - "torlink": "dist/index.js" + "torlnk": "dist/cli.cjs" }, "devDependencies": { "@types/node": "^25.9.2", diff --git a/package.json b/package.json index 4862560..03e333c 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "A sleek, zero-setup torrent finder and downloader that lives right in your terminal.", "type": "module", "bin": { - "torlnk": "./dist/index.js" + "torlnk": "./dist/cli.cjs" }, "files": [ "dist", @@ -16,6 +16,7 @@ "scripts": { "dev": "tsx src/index.tsx", "build": "tsup", + "postbuild": "cp scripts/cli-entry.cjs dist/cli.cjs && chmod +x dist/cli.cjs", "start": "node dist/index.js", "typecheck": "tsc --noEmit", "test": "vitest run", diff --git a/scripts/cli-entry.cjs b/scripts/cli-entry.cjs new file mode 100644 index 0000000..65fbc09 --- /dev/null +++ b/scripts/cli-entry.cjs @@ -0,0 +1,18 @@ +#!/usr/bin/env node +'use strict'; + +var major = parseInt(process.versions.node.split('.')[0], 10); +if (major < 22) { + process.stderr.write( + '\ntorlnk requires Node.js v22 or later.\n' + + 'You are running v' + process.versions.node + '.\n\n' + + 'Upgrade: https://nodejs.org\n' + + 'With nvm: nvm install 22 && nvm use 22\n\n' + ); + process.exit(1); +} + +import('./index.js').catch(function (err) { + process.stderr.write(String((err && err.message) || err) + '\n'); + process.exit(1); +});