Skip to content

Commit f7882dd

Browse files
committed
refactor: don't print builtin command
1 parent dbb1dbf commit f7882dd

3 files changed

Lines changed: 27 additions & 17 deletions

File tree

crates/vite_task/src/config/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pub struct ResolvedTask {
6565
pub args: Arc<[Str]>,
6666
pub resolved_config: ResolvedTaskConfig,
6767
pub resolved_command: ResolvedTaskCommand,
68+
pub is_builtin: bool,
6869
/// If true, the task will not be replayed from the cache.
6970
/// This is useful for tasks that should not be replayed, like auto run install command.
7071
/// TODO: this is a temporary solution, we should find a better way to handle this.
@@ -162,6 +163,7 @@ impl ResolvedTask {
162163
args: args.map(|arg| arg.as_ref().into()).collect(),
163164
resolved_config: resolved_task_config,
164165
resolved_command,
166+
is_builtin: true,
165167
ignore_replay,
166168
})
167169
}

crates/vite_task/src/config/workspace.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ impl Workspace {
229229
args: task_args,
230230
resolved_command,
231231
resolved_config,
232+
is_builtin: false,
232233
ignore_replay: false,
233234
})
234235
}

crates/vite_task/src/schedule.rs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ impl ExecutionPlan {
8282

8383
let command = step.resolved_command.fingerprint.command.clone();
8484
let cwd = step.resolved_command.fingerprint.cwd.clone();
85-
let pretty_command = format!("~/{}$ {}", cwd, command);
85+
let display_command: Option<String> =
86+
if step.is_builtin { None } else { Some(format!("~/{}$ {}", cwd, command)) };
8687
let ignore_replay = step.ignore_replay;
8788

8889
// Check cache and prepare execution
@@ -98,28 +99,34 @@ impl ExecutionPlan {
9899
match cache_miss {
99100
Some(CacheMiss::NotFound) => {
100101
tracing::debug!("{}", "Cache not found".style(Style::new().yellow()));
101-
println!(
102-
"{} {}",
103-
"►".style(Style::new().bright_blue()),
104-
pretty_command.style(Style::new().cyan())
105-
);
102+
if let Some(display_command) = display_command {
103+
println!(
104+
"{} {}",
105+
"►".style(Style::new().bright_blue()),
106+
display_command.style(Style::new().cyan())
107+
);
108+
}
106109
}
107110
Some(CacheMiss::FingerprintMismatch(mismatch)) => {
108111
println!("{}: {}", "Cache miss".style(Style::new().yellow()), mismatch);
109-
println!(
110-
"{} {}",
111-
"►".style(Style::new().bright_blue()),
112-
pretty_command.style(Style::new().cyan())
113-
);
112+
if let Some(display_command) = display_command {
113+
println!(
114+
"{} {}",
115+
"►".style(Style::new().bright_blue()),
116+
display_command.style(Style::new().cyan())
117+
);
118+
}
114119
}
115120
None => {
116121
if !ignore_replay {
117-
println!(
118-
"{} {} {}",
119-
"►".style(Style::new().bright_green()),
120-
pretty_command.style(Style::new().dimmed()),
121-
"(Cache hit, replaying)".style(Style::new().green())
122-
);
122+
println!("{}", "Cache hit, replaying".style(Style::new().green()));
123+
if let Some(display_command) = display_command {
124+
println!(
125+
"{} {}",
126+
"►".style(Style::new().bright_green()),
127+
display_command.style(Style::new().dimmed())
128+
);
129+
}
123130
}
124131
}
125132
}

0 commit comments

Comments
 (0)