Skip to content

Commit ba8e80a

Browse files
committed
Show both suffixes if multiple package specs with different extensions are present.
1 parent 2cd9996 commit ba8e80a

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

rewatch/src/build/clean.rs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub fn remove_compile_assets(package: &packages::Package, source_file: &Path) {
6161
}
6262
}
6363

64-
fn clean_source_files(build_state: &BuildState, root_config: &Config, suffix: &str) {
64+
fn clean_source_files(build_state: &BuildState, root_config: &Config) {
6565
// get all rescript file locations
6666
let rescript_file_locations = build_state
6767
.modules
@@ -77,7 +77,7 @@ fn clean_source_files(build_state: &BuildState, root_config: &Config, suffix: &s
7777
Some((
7878
package.path.join(&source_file.implementation.path),
7979
match spec.suffix {
80-
None => suffix.to_owned(),
80+
None => root_config.get_suffix(&spec),
8181
Some(suffix) => suffix,
8282
},
8383
))
@@ -367,19 +367,40 @@ pub fn clean(path: &Path, show_progress: bool, snapshot_output: bool, clean_dev_
367367
let mut build_state = BuildState::new(project_context, packages, bsc_path);
368368
packages::parse_packages(&mut build_state);
369369
let root_config = build_state.get_root_config();
370-
let suffix = build_state.project_context.get_suffix();
370+
let suffix_for_print = if snapshot_output || !show_progress {
371+
String::new()
372+
} else {
373+
match root_config.package_specs {
374+
None => match &root_config.suffix {
375+
None => String::from(".js"),
376+
Some(suffix) => suffix.clone(),
377+
},
378+
Some(_) => root_config
379+
.get_package_specs()
380+
.into_iter()
381+
.filter_map(|spec| {
382+
if spec.in_source {
383+
spec.suffix.or_else(|| root_config.suffix.clone())
384+
} else {
385+
None
386+
}
387+
})
388+
.collect::<Vec<String>>()
389+
.join(", "),
390+
}
391+
};
371392

372393
if !snapshot_output && show_progress {
373394
println!(
374395
"{} {}Cleaning {} files...",
375396
style("[2/2]").bold().dim(),
376397
SWEEP,
377-
suffix
398+
suffix_for_print
378399
);
379400
let _ = std::io::stdout().flush();
380401
}
381402

382-
clean_source_files(&build_state, root_config, &suffix);
403+
clean_source_files(&build_state, root_config);
383404
let timing_clean_mjs_elapsed = timing_clean_mjs.elapsed();
384405

385406
if !snapshot_output && show_progress {
@@ -388,7 +409,7 @@ pub fn clean(path: &Path, show_progress: bool, snapshot_output: bool, clean_dev_
388409
LINE_CLEAR,
389410
style("[2/2]").bold().dim(),
390411
SWEEP,
391-
suffix,
412+
suffix_for_print,
392413
timing_clean_mjs_elapsed.as_secs_f64()
393414
);
394415
let _ = std::io::stdout().flush();

rewatch/src/project_context.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,6 @@ impl ProjectContext {
215215
self.get_root_config().path.parent().unwrap()
216216
}
217217

218-
pub fn get_suffix(&self) -> String {
219-
self.get_root_config()
220-
.suffix
221-
.clone()
222-
.unwrap_or(String::from(".res.mjs"))
223-
}
224-
225218
/// Returns the local packages relevant for the current context.
226219
/// Either a single project, all projects from a monorepo or a single package inside a monorepo.
227220
pub fn get_scoped_local_packages(&self, include_dev_deps: bool) -> AHashSet<String> {

0 commit comments

Comments
 (0)