This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

Fix CLI for npm global install — build src/ to dist/ with tsc

Node refuses to run .ts files from node_modules/. The CLI and daemon
now run from dist/ (compiled by tsc). Tests and exports updated to
use dist/ for subprocess spawning.

npm run build is now required before using the CLI locally.

Nathan Herald (Mar 25, 2026, 11:12 PM +0100) ef1c8a4a 0bb700c6

+35 -14
+1 -1
.gitignore
··· 1 1 node_modules/ 2 - bin/cli.js 2 + dist/ 3 3 result
+2 -2
bin/pty
··· 5 5 import { dirname, join } from 'node:path'; 6 6 7 7 const __dirname = dirname(fileURLToPath(import.meta.url)); 8 - const cli = join(__dirname, 'cli.js'); 8 + const cli = join(__dirname, '..', 'dist', 'cli.js'); 9 9 10 10 if (!existsSync(cli)) { 11 - console.error('bin/cli.js not found. Run: npm run build'); 11 + console.error('dist/cli.js not found. Run: npm run build'); 12 12 process.exit(1); 13 13 } 14 14
+11 -5
package.json
··· 1 1 { 2 2 "name": "@myobie/pty", 3 - "version": "0.1.1", 3 + "version": "0.1.2", 4 4 "description": "Persistent terminal sessions with detach/attach support", 5 5 "type": "module", 6 6 "license": "MIT", ··· 19 19 ], 20 20 "files": [ 21 21 "bin/", 22 - "src/", 22 + "dist/", 23 23 "completions/", 24 24 "docs/", 25 25 "README.md", ··· 29 29 "pty": "./bin/pty" 30 30 }, 31 31 "exports": { 32 - "./testing": "./src/testing/index.ts", 33 - "./tui": "./src/tui/index.ts" 32 + "./testing": { 33 + "types": "./dist/testing/index.d.ts", 34 + "default": "./dist/testing/index.js" 35 + }, 36 + "./tui": { 37 + "types": "./dist/tui/index.d.ts", 38 + "default": "./dist/tui/index.js" 39 + } 34 40 }, 35 41 "scripts": { 36 - "build": "esbuild src/cli.ts --bundle --platform=node --format=esm --outfile=bin/cli.js --external:node-pty --external:@xterm/headless --external:@xterm/addon-serialize --external:@preact/signals-core", 42 + "build": "tsc -p tsconfig.build.json", 37 43 "prepublishOnly": "npm run build", 38 44 "prepare": "git config core.hooksPath githooks 2>/dev/null || true; chmod +x node_modules/node-pty/prebuilds/darwin-*/spawn-helper 2>/dev/null || true; sh scripts/update-nix-hash.sh 2>/dev/null || true", 39 45 "install-completions": "sh scripts/install-completions.sh",
+1 -1
src/server.ts
··· 390 390 } 391 391 392 392 /** Entry point when this file is run as the daemon process. */ 393 - if (process.argv[1]?.endsWith("/server.ts")) { 393 + if (process.argv[1]?.endsWith("/server.js")) { 394 394 const config = JSON.parse(process.env.PTY_SERVER_CONFIG ?? "{}"); 395 395 if (!config.name || !config.command) { 396 396 console.error("PTY_SERVER_CONFIG env var required");
+1 -1
src/spawn.ts
··· 18 18 const rows = stdout.rows ?? 24; 19 19 const cols = stdout.columns ?? 80; 20 20 21 - const serverModule = path.join(__dirname, "server.ts"); 21 + const serverModule = path.join(__dirname, "server.js"); 22 22 const config = JSON.stringify({ 23 23 name, 24 24 command,
+2 -2
tests/screenshot.test.ts
··· 861 861 describe("daemon spawning", () => { 862 862 const __dirname = path.dirname(fileURLToPath(import.meta.url)); 863 863 const nodeBin = process.execPath; 864 - const serverModule = path.join(__dirname, "..", "src", "server.ts"); 864 + const serverModule = path.join(__dirname, "..", "dist", "server.js"); 865 865 866 866 it( 867 867 "daemon starts and serves a session via the node spawn mechanism", ··· 1034 1034 describe("immediate attach after daemon start", () => { 1035 1035 const __dirname = path.dirname(fileURLToPath(import.meta.url)); 1036 1036 const nodeBin = process.execPath; 1037 - const serverModule = path.join(__dirname, "..", "src", "server.ts"); 1037 + const serverModule = path.join(__dirname, "..", "dist", "server.js"); 1038 1038 1039 1039 async function spawnDaemonAndWaitForSocket( 1040 1040 name: string,
+2 -2
tests/tui.test.ts
··· 8 8 9 9 const __dirname = path.dirname(fileURLToPath(import.meta.url)); 10 10 const nodeBin = process.execPath; 11 - const cliPath = path.join(__dirname, "..", "src", "cli.ts"); 12 - const serverModule = path.join(__dirname, "..", "src", "server.ts"); 11 + const cliPath = path.join(__dirname, "..", "dist", "cli.js"); 12 + const serverModule = path.join(__dirname, "..", "dist", "server.js"); 13 13 14 14 // Each test gets its own temp session dir 15 15 const testRoot = fs.mkdtempSync(path.join(os.tmpdir(), "ptui-"));
+15
tsconfig.build.json
··· 1 + { 2 + "compilerOptions": { 3 + "target": "ES2022", 4 + "module": "Node16", 5 + "moduleResolution": "Node16", 6 + "strict": true, 7 + "esModuleInterop": true, 8 + "skipLibCheck": true, 9 + "outDir": "dist", 10 + "declaration": true, 11 + "rewriteRelativeImportExtensions": true 12 + }, 13 + "include": ["src"], 14 + "exclude": ["node_modules"] 15 + }