refactor(shell): enhance shell detection and add VP_SHELL override#1658
refactor(shell): enhance shell detection and add VP_SHELL override#1658nekomoyi wants to merge 12 commits into
VP_SHELL override#1658Conversation
Replace VP_SHELL_NU and VP_SHELL_PWSH with a single VP_SHELL env var that accepts shell names (bash, fish, nu, pwsh, cmd). Detection now follows: VP_SHELL → process tree inference → platform default. - Add Shell::from_str for case-insensitive name parsing - Add process tree walking to infer shell from parent processes - Add sysinfo dep for Windows process enumeration - Update shell wrapper scripts to remove shell-specific env vars
These tests assert on `detect_shell()` default fallback, but process tree inference varies across environments (CI uses `shell: bash` on Windows, local machines may have Git Bash), making the result non-deterministic.
✅ Deploy Preview for viteplus-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
5cdc2bc to
7a3ed1c
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors shell detection for the global CLI by consolidating multiple shell-specific env flags into a single VP_SHELL override, and adding process-tree inference to better detect the active shell for output formatting (notably vp env use eval output).
Changes:
- Replaced
VP_SHELL_NU/VP_SHELL_PWSHwith a singleVP_SHELLenv var (case-insensitive parsing + aliases). - Added process-tree based shell inference (
pson Unix,sysinfoon Windows) with a platform-default fallback. - Added global snap tests validating
VP_SHELL-driven formatting across supported shells.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/cli/snap-tests-global/command-env-use-shells/steps.json | Adds snap-test commands covering VP_SHELL parsing and formatting. |
| packages/cli/snap-tests-global/command-env-use-shells/snap.txt | Snapshot output for the new VP_SHELL shell-formatting coverage. |
| packages/cli/snap-tests-global/command-env-use-shells/package.json | Fixture metadata for the new snap-test case. |
| crates/vite_shared/src/env_vars.rs | Replaces shell marker constants with VP_SHELL. |
| crates/vite_shared/src/env_config.rs | Updates EnvConfig to read VP_SHELL (and removes old marker fields). |
| crates/vite_global_cli/src/commands/shell.rs | Implements Shell::FromStr, VP_SHELL override, and process-tree inference. |
| crates/vite_global_cli/src/commands/env/use.rs | Updates tests to use vp_shell: Some(...) instead of old marker booleans. |
| crates/vite_global_cli/src/commands/env/setup.rs | Removes wrapper-set env markers (VP_SHELL_NU, VP_SHELL_PWSH) from generated shell setup scripts. |
| crates/vite_global_cli/Cargo.toml | Adds Windows-only sysinfo dependency for process-tree inference. |
| Cargo.toml | Adds sysinfo to workspace dependencies. |
| Cargo.lock | Lockfile updates due to dependency graph changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7a3ed1ceb9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 271fbd296e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
What changed
VP_SHELL_NUandVP_SHELL_PWSHwith one env var:VP_SHELLbash,zsh,fish,nu,pwsh, andcmdWhy
The old approach depended on a few shell-specific flags and inherited env vars. It could mis-detect nested shells and is harder to maintain.
The new shell detection stages:
VP_SHELLif it is set