Files
webstudio/packages
Oleg Isonen 3aeb4b3f61 fix: Reuse npm launcher for generated previews (#5962)
## Summary

Generated previews now reuse the npm CLI path supplied by the npx
launcher instead of rediscovering npm or npm.cmd through the MCP
subprocess PATH. The same invocation is used for dependency
installation, production builds, and preview server startup, with the
existing platform command retained as a fallback for direct launches.

## Technical choices

- Invoke npm-cli.js with the current Node executable when npm_execpath
identifies npm as the launcher.
- Parse Windows paths with the platform path implementation.
- Keep npm and npm.cmd fallback behavior when Webstudio was not launched
through npm.
- Inject executable paths in tests so launcher behavior is
deterministic.

## Todo

- [x] Reuse the npx npm launcher during generated dependency
installation.
- [x] Apply the same launcher to generated build and server commands.
- [x] Cover Windows launcher paths and direct-launch fallbacks.
- [x] Run focused tests, typecheck, lint, formatting, and production
build.

## Verification

- pnpm --filter webstudio test -- src/commands/preview.test.ts
src/preview-server.test.ts
- pnpm --filter webstudio typecheck
- pnpm exec oxlint --deny-warnings on the four changed files
- pnpm --filter webstudio build
- git diff --check

All checks passed. The build emitted the existing Radix use-client
bundling warnings. Agent evaluations were not run because they require
separate explicit approval.
2026-07-31 00:56:30 +02:00
..