Skip to content

fix: resolve .cmd wrapper to actual JS entry on Windows#32

Merged
homeofe merged 1 commit intomainfrom
fix/windows-bridge-spawn
Mar 24, 2026
Merged

fix: resolve .cmd wrapper to actual JS entry on Windows#32
homeofe merged 1 commit intomainfrom
fix/windows-bridge-spawn

Conversation

@homeofe
Copy link
Copy Markdown
Member

@homeofe homeofe commented Mar 24, 2026

Problem

On Windows, npm install -g conduit-bridge creates a .cmd shim wrapper. The extension was passing this .cmd file to cp.spawn('node', [bridgePath, ...]), causing:

C:\Users\KohlerEmre\AppData\Roaming\npm\conduit-bridge.cmd:1
@ECHO off
^
SyntaxError: Invalid or unexpected token

Bridge would crash 3 times and stop auto-restarting.

Fix

  • New _resolveCmd() method parses the .cmd wrapper to extract the actual JS entry script path
  • _findBridgeCli() now prioritizes direct JS entry points (dist/cli.js) before shell wrappers
  • On Windows, any .cmd candidate is resolved to its JS target before returning
  • Falls back to node_modules/conduit-bridge/dist/cli.js relative to npm prefix

Testing

  • Verified build passes (npm run build)
  • Tested .cmd parsing logic against standard npm-generated shim format

On Windows, npm global installs create a .cmd shim for CLI tools.
The extension was passing this .cmd file to `node`, causing:
  SyntaxError: Invalid or unexpected token (@echo off)

Fix: Parse the .cmd wrapper to extract the real JS entry script path
and pass that to node instead. Falls back to checking
node_modules/conduit-bridge/dist/cli.js directly.

Also prioritizes direct JS entry point candidates before shell wrappers
for more reliable cross-platform behavior.
@homeofe homeofe merged commit 614e352 into main Mar 24, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant