Fix Windows npm self-upgrade spawning

Merged
FE
3mo ago
+160-90

Summary

  • share the existing Windows-safe child-process resolver across setup and upgrade
  • run npm upgrades through node/npm-cli.js instead of an unspawnable npm.cmd shim
  • resolve the installed insta shim safely when verifying the upgraded version

Verification

  • npm run typecheck
  • 28 upgrade resolver tests
  • 5 existing resolveSpawnable tests
  • Windows build-output smoke tests for npm --version and insta --version

Windows regression

Before this change, insta upgrade failed with spawn npm ENOENT. Node also rejects direct npm.cmd spawning with EINVAL. The resolved node entry point now exits 0 on Windows.


Summary by cubic

Fixes Windows npm self-upgrade spawn failures so insta upgrade no longer errors with ENOENT or EINVAL on Windows.

Bug Fixes

  • Moves the Windows-safe resolver into a shared src/spawn.ts used by both setup and upgrade.
  • Runs npm upgrades through node/npm-cli.js instead of the unspawnable npm.cmd shim.
  • Resolves the installed insta shim safely when verifying the upgraded version.
  • Launches .cmd shims via an absolute System32 cmd.exe (resolved from SYSTEMROOT) and skips the wrapper when a PATH directory or shim path contains shell metacharacters.
  • Looks up PATH/PATHEXT case-insensitively, so the version probe still resolves shims through copied environments that keep Windows' Path casing.