@lesscap/baton-cli 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lesscap/baton-cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "baton CLI — register/run a worker, manage projects/requirements/tasks/sessions",
@@ -1,16 +1,25 @@
1
- // Ensure node-pty's native addon actually loads after install. Its prebuilt
2
- // binaries don't cover every Node version (24/26 ship none, or a partial one that
3
- // installs without a working spawn-helper), so the bundle would crash the first
4
- // time a worker opens a terminal. If it won't load, rebuild it from source (needs
5
- // python3 + a C++ toolchain). Non-fatal: a worker that can't build it simply has
6
- // interactive terminals disabled, while the headless relay keeps working.
1
+ // Ensure node-pty can actually spawn a pty after install. Its prebuilt binaries
2
+ // are unreliable on newer Node (24/26 ship a partial one whose pty.node loads but
3
+ // whose spawn-helper fails with `posix_spawnp failed`), so a plain require() isn't
4
+ // a real check — spawn a throwaway pty. If that fails, rebuild from source (needs
5
+ // python3 + a C++ toolchain). Non-fatal: a host that can't build it just loses
6
+ // interactive terminals, while the headless relay keeps working.
7
7
  import { execSync } from 'node:child_process'
8
8
  import { createRequire } from 'node:module'
9
9
 
10
10
  const require = createRequire(import.meta.url)
11
- try {
12
- require('node-pty')
13
- } catch {
11
+
12
+ const works = () => {
13
+ try {
14
+ const pty = require('node-pty')
15
+ pty.spawn(process.platform === 'win32' ? 'cmd.exe' : '/bin/sh', [], { cols: 80, rows: 24 }).kill()
16
+ return true
17
+ } catch {
18
+ return false
19
+ }
20
+ }
21
+
22
+ if (!works()) {
14
23
  try {
15
24
  execSync('npm rebuild node-pty --build-from-source', { stdio: 'inherit' })
16
25
  } catch {