Skip to content

Commit dec7324

Browse files
liangmiQwQcodex
andcommitted
fix: narrow user-facing display formatting
Co-authored-by: GPT-5 Codex <codex@openai.com>
1 parent f2d56ed commit dec7324

4 files changed

Lines changed: 7 additions & 68 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
- **Fixed** Vite+ diagnostics now display paths and commands without Rust debug formatting such as escaped backslashes, wrapper types, or list syntax ([#534](https://github.com/voidzero-dev/vite-task/pull/534)).
3+
- **Fixed** Vite+ diagnostics now display individual paths and working directories without Rust debug formatting such as quoted paths or escaped Windows backslashes ([#534](https://github.com/voidzero-dev/vite-task/pull/534)).
44
- **Fixed** Windows automatic input tracking now records executable image reads when process creation performs the lookup inside `NtCreateUserProcess` ([#518](https://github.com/voidzero-dev/vite-task/pull/518)).
55
- **Fixed** Failures while waiting for a started task process to exit no longer incorrectly say the process failed to spawn ([#515](https://github.com/voidzero-dev/vite-task/pull/515)).
66
- **Fixed** Missing env vars requested through `@voidzero-dev/vite-task-client` now return `undefined` instead of `null`, preserving Vite production `NODE_ENV` semantics when builds run through `vp run` ([#508](https://github.com/voidzero-dev/vite-task/pull/508)).

crates/fspy/src/error.rs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
use std::{
2-
ffi::{OsStr, OsString},
3-
fmt,
4-
path::PathBuf,
5-
};
1+
use std::{ffi::OsString, path::PathBuf};
62

73
#[derive(thiserror::Error, Debug)]
84
pub enum SpawnError {
95
#[error(
106
"could not resolve the full path of program '{}' with PATH={} under cwd({})",
117
.program.display(),
12-
display_path_env(.path.as_deref()),
8+
.path.as_deref().unwrap_or_else(|| std::ffi::OsStr::new("<not set>")).display(),
139
.cwd.display()
1410
)]
1511
Which {
@@ -34,18 +30,3 @@ pub enum SpawnError {
3430
#[error("underlying os error: {0}")]
3531
OsSpawn(std::io::Error),
3632
}
37-
38-
struct DisplayPathEnv<'a>(Option<&'a OsStr>);
39-
40-
impl fmt::Display for DisplayPathEnv<'_> {
41-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42-
match self.0 {
43-
Some(path) => fmt::Display::fmt(&path.display(), f),
44-
None => f.write_str("<not set>"),
45-
}
46-
}
47-
}
48-
49-
const fn display_path_env(path: Option<&OsStr>) -> DisplayPathEnv<'_> {
50-
DisplayPathEnv(path)
51-
}

crates/vite_task_graph/src/lib.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub mod loader;
44
pub mod query;
55
mod specifier;
66

7-
use std::{convert::Infallible, fmt, sync::Arc};
7+
use std::{convert::Infallible, sync::Arc};
88

99
use config::{
1010
ResolvedGlobalCacheConfig, ResolvedTaskConfig, UserRunConfig, UserTaskConfig,
@@ -138,10 +138,7 @@ pub enum TaskGraphLoadError {
138138
/// - When the specifier is from a CLI command, `UnknownPackageError` can be a real error type in case cwd is not in any package.
139139
#[derive(Debug, thiserror::Error, Serialize)]
140140
pub enum SpecifierLookupError<PackageUnknownError = Infallible> {
141-
#[error(
142-
"Package '{package_name}' is ambiguous among multiple packages: {}",
143-
display_package_paths(.package_paths)
144-
)]
141+
#[error("Package '{package_name}' is ambiguous among multiple packages: {package_paths:?}")]
145142
AmbiguousPackageName { package_name: Str, package_paths: Box<[Arc<AbsolutePath>]> },
146143

147144
#[error("Package '{package_name}' not found")]
@@ -161,24 +158,6 @@ pub enum SpecifierLookupError<PackageUnknownError = Infallible> {
161158
PackageUnknown { unspecifier_package_error: PackageUnknownError, task_name: Str },
162159
}
163160

164-
struct DisplayPackagePaths<'a>(&'a [Arc<AbsolutePath>]);
165-
166-
impl fmt::Display for DisplayPackagePaths<'_> {
167-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
168-
for (index, path) in self.0.iter().enumerate() {
169-
if index > 0 {
170-
f.write_str(", ")?;
171-
}
172-
fmt::Display::fmt(&path.as_path().display(), f)?;
173-
}
174-
Ok(())
175-
}
176-
}
177-
178-
const fn display_package_paths(paths: &[Arc<AbsolutePath>]) -> DisplayPackagePaths<'_> {
179-
DisplayPackagePaths(paths)
180-
}
181-
182161
/// newtype of `DefaultIx` for indices in task graphs
183162
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
184163
pub struct TaskIx(DefaultIx);

crates/vite_task_plan/src/error.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
reason = "Arc<Path> is used for non-UTF-8 path data in error types"
44
)]
55
use std::path::Path;
6-
use std::{env::JoinPathsError, ffi::OsStr, fmt, sync::Arc};
6+
use std::{env::JoinPathsError, ffi::OsStr, sync::Arc};
77

88
use vite_path::{AbsolutePath, relative::InvalidPathDataError};
99
use vite_str::Str;
@@ -124,8 +124,7 @@ pub enum Error {
124124
TaskRecursionDetected(#[from] TaskRecursionError),
125125

126126
#[error(
127-
"Invalid Vite+ command: {} under cwd {}",
128-
display_command(.program.as_str(), .args),
127+
"Invalid vite task command: {program} with args {args:?} under cwd {}",
129128
.cwd.as_path().display()
130129
)]
131130
ParsePlanRequest {
@@ -184,23 +183,3 @@ pub enum Error {
184183
#[error("Cycle dependency detected: {}", _0.iter().map(std::string::ToString::to_string).collect::<Vec<_>>().join(" -> "))]
185184
CycleDependencyDetected(Vec<TaskDisplay>),
186185
}
187-
188-
struct DisplayCommand<'a> {
189-
program: &'a str,
190-
args: &'a [Str],
191-
}
192-
193-
impl fmt::Display for DisplayCommand<'_> {
194-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
195-
fmt::Display::fmt(&shell_escape::escape(self.program.into()), f)?;
196-
for arg in self.args {
197-
f.write_str(" ")?;
198-
fmt::Display::fmt(&shell_escape::escape(arg.as_str().into()), f)?;
199-
}
200-
Ok(())
201-
}
202-
}
203-
204-
const fn display_command<'a>(program: &'a str, args: &'a [Str]) -> DisplayCommand<'a> {
205-
DisplayCommand { program, args }
206-
}

0 commit comments

Comments
 (0)