Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ simdutf8 = "0.1.5"
string_cache = "0.9.0"
sugar_path = { version = "2.0.1", features = ["cached_current_dir"] }
syn = { version = "2", default-features = false }
sysinfo = "0.39.2"
tar = "0.4.43"
tempfile = "3.14.0"
terminal_size = "0.4.2"
Expand Down
3 changes: 3 additions & 0 deletions crates/vite_global_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ vite_shared = { workspace = true }
vite_str = { workspace = true }
vite_workspace = { workspace = true }

[target.'cfg(windows)'.dependencies]
sysinfo = { workspace = true }

[dev-dependencies]
serial_test = { workspace = true }
tempfile = { workspace = true }
Expand Down
8 changes: 1 addition & 7 deletions crates/vite_global_cli/src/commands/env/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def --env --wrapped vp [...args: string@"nu-complete vp"] {
^vp ...$args
return
}
let out = (with-env { VP_ENV_USE_EVAL_ENABLE: "1", VP_SHELL_NU: "1" } {
let out = (with-env { VP_ENV_USE_EVAL_ENABLE: "1" } {
Comment thread
nekomoyi marked this conversation as resolved.
Outdated
^vp ...$args
})
let lines = ($out | lines)
Expand Down Expand Up @@ -625,7 +625,6 @@ function vp {
& (Join-Path $__vp_bin "vp") @args; return
}
$env:VP_ENV_USE_EVAL_ENABLE = "1"
$env:VP_SHELL_PWSH = "1"
$output = & (Join-Path $__vp_bin "vp") @args 2>&1 | ForEach-Object {
if ($_ -is [System.Management.Automation.ErrorRecord]) {
Write-Host $_.Exception.Message
Expand All @@ -634,7 +633,6 @@ function vp {
}
}
Remove-Item Env:VP_ENV_USE_EVAL_ENABLE -ErrorAction SilentlyContinue
Remove-Item Env:VP_SHELL_PWSH -ErrorAction SilentlyContinue
if ($LASTEXITCODE -eq 0 -and $output) {
Comment thread
nekomoyi marked this conversation as resolved.
Invoke-Expression ($output -join "`n")
}
Expand Down Expand Up @@ -848,10 +846,6 @@ mod tests {
nu_content.contains("VP_COMPLETE=fish"),
"env.nu should use dynamic Fish completion delegation"
);
assert!(
nu_content.contains("VP_SHELL_NU"),
"env.nu should use VP_SHELL_NU explicit marker instead of inherited NU_VERSION"
);
assert!(nu_content.contains("load-env"), "env.nu should use load-env to apply exports");
}

Expand Down
59 changes: 10 additions & 49 deletions crates/vite_global_cli/src/commands/env/use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,72 +181,33 @@ mod tests {
use super::*;

#[test]
fn test_detect_shell_pwsh() {
fn test_detect_shell_vp_shell_powershell() {
let _guard = vite_shared::EnvConfig::test_guard(vite_shared::EnvConfig {
vp_shell_pwsh: true,
vp_shell: Some("powershell".into()),
..vite_shared::EnvConfig::for_test()
});
let shell = detect_shell();
assert!(matches!(shell, Shell::PowerShell));
assert_eq!(shell, Shell::PowerShell);
}

#[test]
fn test_detect_shell_fish() {
fn test_detect_shell_vp_shell_fish() {
let _guard = vite_shared::EnvConfig::test_guard(vite_shared::EnvConfig {
fish_version: Some("3.7.0".into()),
vp_shell: Some("fish".into()),
..vite_shared::EnvConfig::for_test()
});
let shell = detect_shell();
assert!(matches!(shell, Shell::Fish));
assert_eq!(shell, Shell::Fish);
}

#[test]
fn test_detect_shell_fish_and_nushell() {
// Fish takes priority over Nu shell signal
fn test_detect_shell_vp_shell_nu() {
let _guard = vite_shared::EnvConfig::test_guard(vite_shared::EnvConfig {
fish_version: Some("3.7.0".into()),
vp_shell_nu: true,
vp_shell: Some("nu".into()),
..vite_shared::EnvConfig::for_test()
});
let shell = detect_shell();
assert!(matches!(shell, Shell::Fish));
}

#[test]
fn test_detect_shell_posix_default() {
// All shell detection fields None → defaults
let _guard = vite_shared::EnvConfig::test_guard(vite_shared::EnvConfig::for_test());
let shell = detect_shell();
#[cfg(not(windows))]
assert!(matches!(shell, Shell::Posix));
#[cfg(windows)]
assert!(matches!(shell, Shell::Cmd));
}

#[test]
fn test_detect_shell_nushell() {
let _guard = vite_shared::EnvConfig::test_guard(vite_shared::EnvConfig {
vp_shell_nu: true,
..vite_shared::EnvConfig::for_test()
});
let shell = detect_shell();
assert!(matches!(shell, Shell::NuShell));
}

#[test]
fn test_detect_shell_inherited_nu_version_is_posix() {
// NU_VERSION alone (inherited from parent Nushell) must NOT trigger Nu detection.
// Only the explicit VP_SHELL_NU marker set by env.nu wrapper counts.
let _guard = vite_shared::EnvConfig::test_guard(vite_shared::EnvConfig {
nu_version: Some("0.111.0".into()),
vp_shell_nu: false,
..vite_shared::EnvConfig::for_test()
});
let shell = detect_shell();
#[cfg(not(windows))]
assert!(matches!(shell, Shell::Posix));
#[cfg(windows)]
let _ = shell;
assert_eq!(shell, Shell::NuShell);
}

#[test]
Expand Down Expand Up @@ -346,7 +307,7 @@ mod tests {
let cwd = AbsolutePathBuf::new(temp_dir.path().to_path_buf()).unwrap();
let _guard = vite_shared::EnvConfig::test_guard(vite_shared::EnvConfig {
env_use_eval_enable: true,
vp_shell_pwsh: true,
vp_shell: Some("powershell".into()),
..vite_shared::EnvConfig::for_test_with_home(temp_dir.path())
});

Expand Down
Loading
Loading