Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
1233c47
fix(command): route Windows .cmd shims through PowerShell for pm comm…
fengmk2 Apr 29, 2026
ebbace4
refactor(command): extract resolve_program to dedupe ps1-rewrite plum…
fengmk2 Apr 29, 2026
8625842
refactor(command): use shared vite_powershell crate for ps1 rewrite
fengmk2 Apr 29, 2026
121a544
chore(deps): bump vite-task pin to 957278df
fengmk2 Apr 29, 2026
fbf831a
style(command): import OsString and drop Arc turbofish in ps1_shim
fengmk2 Apr 29, 2026
221b88a
fix(command): look up PATH case-insensitively in resolve_program
fengmk2 Apr 29, 2026
466b3a5
fix(command): restrict .cmd to PowerShell rewrite to vp-managed shims
fengmk2 Apr 29, 2026
6a52487
style(ps1_shim): tighten scope-rationale doc and unshadow ps1_str in …
fengmk2 Apr 29, 2026
5d59d65
fix(command): also rewrite .cmd shims under any node_modules/.bin
fengmk2 Apr 30, 2026
35ba866
chore(deps): bump vite-task pin to merged 88bacaa7
fengmk2 Apr 30, 2026
3c3750a
refactor(command): drop case-insensitive PATH lookup in resolve_program
fengmk2 Apr 30, 2026
408c0d4
style(ps1_shim): drop Arc from rewrite_in_scope signature and trim do…
fengmk2 Apr 30, 2026
afde39a
fix(cli): consolidate runCommandSilently and skip stdin pipe to avoid…
fengmk2 Apr 30, 2026
c36baab
fix(command): restore run_command_with_fspy to its pre-branch form
fengmk2 Apr 30, 2026
f1fe113
refactor(cli): move projectDir off ExecutionResult into ExecutionWith…
fengmk2 Apr 30, 2026
d56a742
refactor(cli): drop dead re-exports from create/command.ts
fengmk2 Apr 30, 2026
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
54 changes: 33 additions & 21 deletions Cargo.lock

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

14 changes: 8 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ dunce = "1.0.5"
fast-glob = "1.0.0"
flate2 = { version = "=1.1.9", features = ["zlib-rs"] }
form_urlencoded = "1.2.1"
fspy = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "d1b8cdae8b6df5eab8b9f1143ceb4fb13933a5ef" }
fspy = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "88bacaa770200ddab151dea252e04ba8cdcc4ade" }
futures = "0.3.31"
futures-util = "0.3.31"
glob = "0.3.2"
Expand Down Expand Up @@ -194,16 +194,17 @@ vfs = "0.13.0"
vite_command = { path = "crates/vite_command" }
vite_error = { path = "crates/vite_error" }
vite_js_runtime = { path = "crates/vite_js_runtime" }
vite_glob = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "d1b8cdae8b6df5eab8b9f1143ceb4fb13933a5ef" }
vite_glob = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "88bacaa770200ddab151dea252e04ba8cdcc4ade" }
vite_install = { path = "crates/vite_install" }
vite_migration = { path = "crates/vite_migration" }
vite_setup = { path = "crates/vite_setup" }
vite_shared = { path = "crates/vite_shared" }
vite_static_config = { path = "crates/vite_static_config" }
vite_path = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "d1b8cdae8b6df5eab8b9f1143ceb4fb13933a5ef" }
vite_str = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "d1b8cdae8b6df5eab8b9f1143ceb4fb13933a5ef" }
vite_task = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "d1b8cdae8b6df5eab8b9f1143ceb4fb13933a5ef" }
vite_workspace = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "d1b8cdae8b6df5eab8b9f1143ceb4fb13933a5ef" }
vite_path = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "88bacaa770200ddab151dea252e04ba8cdcc4ade" }
vite_powershell = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "88bacaa770200ddab151dea252e04ba8cdcc4ade" }
vite_str = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "88bacaa770200ddab151dea252e04ba8cdcc4ade" }
vite_task = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "88bacaa770200ddab151dea252e04ba8cdcc4ade" }
vite_workspace = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "88bacaa770200ddab151dea252e04ba8cdcc4ade" }
walkdir = "2.5.0"
wax = "0.6.0"
which = "8.0.0"
Expand Down Expand Up @@ -314,6 +315,7 @@ string_wizard = { path = "./rolldown/crates/string_wizard", features = ["serde"]
# fspy = { path = "../vite-task/crates/fspy" }
# vite_glob = { path = "../vite-task/crates/vite_glob" }
# vite_path = { path = "../vite-task/crates/vite_path" }
# vite_powershell = { path = "../vite-task/crates/vite_powershell" }
# vite_str = { path = "../vite-task/crates/vite_str" }
# vite_task = { path = "../vite-task/crates/vite_task" }
# vite_workspace = { path = "../vite-task/crates/vite_workspace" }
Expand Down
2 changes: 2 additions & 0 deletions crates/vite_command/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ tokio-util = { workspace = true }
tracing = { workspace = true }
vite_error = { workspace = true }
vite_path = { workspace = true }
vite_powershell = { workspace = true }
vite_shared = { workspace = true }
which = { workspace = true, features = ["tracing"] }

[target.'cfg(not(target_os = "windows"))'.dependencies]
Expand Down
27 changes: 22 additions & 5 deletions crates/vite_command/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::os::fd::{BorrowedFd, RawFd};
use std::{
collections::HashMap,
ffi::OsStr,
ffi::{OsStr, OsString},
process::{ExitStatus, Stdio},
};

Expand All @@ -12,6 +12,8 @@ use tokio_util::sync::CancellationToken;
use vite_error::Error;
use vite_path::{AbsolutePath, AbsolutePathBuf, RelativePathBuf};

mod ps1_shim;

/// Result of running a command with fspy tracking.
#[derive(Debug)]
pub struct FspyCommandResult {
Expand Down Expand Up @@ -43,6 +45,22 @@ pub fn resolve_bin(
AbsolutePathBuf::new(path).ok_or_else(|| Error::CannotFindBinaryPath(bin_name.into()))
}

/// Resolve `bin_name` to a path and apply the Windows `.cmd` → PowerShell
/// rewrite. Returns the program to spawn and the arg prefix to prepend
/// before the user args (empty when no rewrite applies).
fn resolve_program(
bin_name: &str,
envs: &HashMap<String, String>,
cwd: &AbsolutePath,
) -> Result<(AbsolutePathBuf, Vec<OsString>), Error> {
let path_env = envs.get("PATH").map(|p| OsStr::new(p.as_str()));
let bin_path = resolve_bin(bin_name, path_env, cwd)?;
Ok(match ps1_shim::rewrite_cmd_to_powershell(&bin_path) {
Some(rewritten) => rewritten,
None => (bin_path, Vec::new()),
})
}

/// Build a `tokio::process::Command` for a pre-resolved binary path.
/// Sets inherited stdio and `fix_stdio_streams` (Unix pre_exec).
/// Callers can further customize (add args, envs, override stdio, etc.).
Expand Down Expand Up @@ -140,10 +158,9 @@ where
S: AsRef<OsStr>,
{
let cwd = cwd.as_ref();
let paths = envs.get("PATH");
let bin_path = resolve_bin(bin_name, paths.map(|p| OsStr::new(p.as_str())), cwd)?;
let mut cmd = build_command(&bin_path, cwd);
cmd.args(args).envs(envs);
let (program, prefix_args) = resolve_program(bin_name, envs, cwd)?;
let mut cmd = build_command(&program, cwd);
cmd.args(&prefix_args).args(args).envs(envs);
let status = cmd.status().await?;
Ok(status)
}
Expand Down
Loading
Loading