Skip to content

Commit 736159e

Browse files
authored
Use root package suffix in clean log messages (#7648)
* Use root package suffix in clean log messages * Mention RESCRIPT_BSC_EXE if not set. * Add changelog entry
1 parent f26d5c9 commit 736159e

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
#### :bug: Bug fix
3434

3535
- Fix `typeof` parens on functions. https://github.com/rescript-lang/rescript/pull/7643
36-
- Add --dev flag to clean command. https://github.com/rescript-lang/rescript/pull/7622
36+
- Rewatch: Add --dev flag to clean command. https://github.com/rescript-lang/rescript/pull/7622
37+
- Rewatch: Use root package suffix in clean log messages. https://github.com/rescript-lang/rescript/pull/7648
3738

3839
# 12.0.0-beta.1
3940

rewatch/src/build/clean.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,14 @@ pub fn remove_compile_assets(package: &packages::Package, source_file: &Path) {
5858
}
5959
}
6060

61-
pub fn clean_mjs_files(build_state: &BuildState) {
61+
fn clean_source_files(build_state: &BuildState, root_package: &packages::Package) {
6262
// get all rescript file locations
6363
let rescript_file_locations = build_state
6464
.modules
6565
.values()
6666
.filter_map(|module| match &module.source_type {
6767
SourceType::SourceFile(source_file) => {
6868
let package = build_state.packages.get(&module.package_name).unwrap();
69-
let root_package = build_state
70-
.packages
71-
.get(&build_state.root_config_name)
72-
.expect("Could not find root package");
73-
7469
Some(
7570
root_package
7671
.config
@@ -391,10 +386,6 @@ pub fn clean(path: &Path, show_progress: bool, snapshot_output: bool, build_dev_
391386
}
392387

393388
let timing_clean_mjs = Instant::now();
394-
if !snapshot_output && show_progress {
395-
println!("{} {}Cleaning mjs files...", style("[2/2]").bold().dim(), SWEEP);
396-
let _ = std::io::stdout().flush();
397-
}
398389
let mut build_state = BuildState::new(
399390
project_root.to_owned(),
400391
root_config_name,
@@ -403,15 +394,33 @@ pub fn clean(path: &Path, show_progress: bool, snapshot_output: bool, build_dev_
403394
bsc_path,
404395
);
405396
packages::parse_packages(&mut build_state);
406-
clean_mjs_files(&build_state);
397+
let root_package = build_state
398+
.packages
399+
.get(&build_state.root_config_name)
400+
.expect("Could not find root package");
401+
402+
let suffix = root_package.config.suffix.as_deref().unwrap_or(".res.mjs");
403+
404+
if !snapshot_output && show_progress {
405+
println!(
406+
"{} {}Cleaning {} files...",
407+
style("[2/2]").bold().dim(),
408+
SWEEP,
409+
suffix
410+
);
411+
let _ = std::io::stdout().flush();
412+
}
413+
414+
clean_source_files(&build_state, root_package);
407415
let timing_clean_mjs_elapsed = timing_clean_mjs.elapsed();
408416

409417
if !snapshot_output && show_progress {
410418
println!(
411-
"{}{} {}Cleaned mjs files in {:.2}s",
419+
"{}{} {}Cleaned {} files in {:.2}s",
412420
LINE_CLEAR,
413421
style("[2/2]").bold().dim(),
414422
SWEEP,
423+
suffix,
415424
timing_clean_mjs_elapsed.as_secs_f64()
416425
);
417426
let _ = std::io::stdout().flush();

rewatch/src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ pub fn get_bsc() -> PathBuf {
196196

197197
bsc_path
198198
.canonicalize()
199-
.expect("Could not get bsc path")
199+
.expect("Could not get bsc path, did you set environment variable RESCRIPT_BSC_EXE ?")
200200
.to_stripped_verbatim_path()
201201
}
202202

0 commit comments

Comments
 (0)