pub fn resolve_cli_spawn_target(cli_path: &str) -> Option<(String, Vec<String>)>Expand description
Resolve cli_path to the actual (program, args) spawn target — the
.cmd/.bat shim parsing on Windows, factored out of build_cli_cmd so
non-tokio::process::Command spawners (e.g. portable_pty::CommandBuilder,
which run_cli_login_pty uses) can reuse the same resolution instead of
spawning the raw shim path directly. Spawning a .cmd file straight
through CommandBuilder forces Windows through cmd.exe /c, and that
layer hangs indefinitely under a real ConPTY (confirmed live: 0% CPU, zero
output, target dir never created) — this is the fix for that class of bug,
not just a refactor for its own sake.
Returns None when cli_path is a .cmd/.bat shim that doesn’t match
either known npm shape (Node-script or native-exe). A previous version
fell back to ("cmd.exe", ["/C", cli_path]) here, but that’s the exact
invocation this function exists to avoid — under a ConPTY it hangs just
as indefinitely as the raw shim path did, silently reintroducing the bug
for any unrecognized shim shape (reagent P2 on PR review). Callers must
decide how to handle an unresolvable shim themselves: build_cli_cmd
(piped stdio, no ConPTY) falls back to the raw path, which loses some
stdio fidelity but doesn’t hang; run_cli_login_pty (real ConPTY) must
fail fast instead of attempting a doomed spawn.