Skip to content

Commit ff35b9a

Browse files
Address watch recovery documentation and output nits
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
1 parent b7ff3d5 commit ff35b9a

11 files changed

Lines changed: 12 additions & 28 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
- Keep watch mode running after full rebuild initialization fails, retry initialization on source edits, and watch newly added dependencies for configuration fixes. https://github.com/rescript-lang/rescript/pull/8641
2+
- Dependency resolution and configuration errors now return exit code `1` instead of `2` from `rescript build`, `clean`, and `format`. https://github.com/rescript-lang/rescript/pull/8641

‎rewatch/src/build.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ pub fn initialize_build(
186186
let compiler = get_compiler_info(&project_context)?;
187187

188188
let timing_clean_start = Instant::now();
189-
let packages = packages::make(filter, &project_context, show_progress, prod, features.as_ref())?;
189+
let packages = packages::make(filter, &project_context, prod, features.as_ref())?;
190190

191191
let source_map_args = project_context
192192
.get_root_config()

‎rewatch/src/build/clean.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ pub fn clean(path: &Path, show_progress: bool, plain_output: bool, prod: bool) -
346346
// `clean` always acts on the full set of source directories regardless of which features are
347347
// active. We explicitly pass `None` so every tagged source folder is included and its
348348
// artifacts can be removed, even for features the user hasn't enabled for this build.
349-
let packages = packages::make(&None, &project_context, show_progress, prod, None)?;
349+
let packages = packages::make(&None, &project_context, prod, None)?;
350350

351351
let timing_clean_compiler_assets = Instant::now();
352352
if !plain_output && show_progress {

‎rewatch/src/build/packages.rs‎

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::helpers::emojis::*;
99
use crate::project_context::{MonoRepoContext, ProjectContext};
1010
use ahash::{AHashMap, AHashSet};
1111
use anyhow::{Context, Result, anyhow};
12-
use console::style;
1312
use log::debug;
1413
use rayon::prelude::*;
1514
use std::collections::hash_map::Entry;
@@ -318,7 +317,6 @@ fn read_dependencies(
318317
registered_dependencies_set: &mut AHashSet<String>,
319318
project_context: &ProjectContext,
320319
package_config: &Config,
321-
show_progress: bool,
322320
is_local_dep: bool,
323321
prod: bool,
324322
) -> Result<Vec<Dependency>> {
@@ -372,16 +370,6 @@ fn read_dependencies(
372370
.par_iter()
373371
.map(|package_name| -> Result<Dependency> {
374372
let canonical_path = read_dependency(package_name, package_config, project_context)
375-
.inspect_err(|error| {
376-
if show_progress {
377-
println!(
378-
"{} {} Error building package tree. {}",
379-
style("[1/2]").bold().dim(),
380-
CROSS,
381-
error
382-
);
383-
}
384-
})
385373
.with_context(|| {
386374
format!("Could not build package tree reading dependency '{package_name}'")
387375
})?;
@@ -396,7 +384,6 @@ fn read_dependencies(
396384
&mut registered_dependencies_set.to_owned(),
397385
project_context,
398386
&config,
399-
show_progress,
400387
is_local_dep,
401388
prod,
402389
)
@@ -567,11 +554,7 @@ This inconsistency will cause issues with package resolution.\n",
567554
})
568555
}
569556

570-
fn read_packages(
571-
project_context: &ProjectContext,
572-
show_progress: bool,
573-
prod: bool,
574-
) -> Result<AHashMap<String, Package>> {
557+
fn read_packages(project_context: &ProjectContext, prod: bool) -> Result<AHashMap<String, Package>> {
575558
// Store all packages and completely deduplicate them
576559
let mut map: AHashMap<String, Package> = AHashMap::new();
577560

@@ -591,7 +574,6 @@ fn read_packages(
591574
&mut registered_dependencies_set,
592575
project_context,
593576
&project_context.current_config,
594-
show_progress,
595577
/* is local dep */ true,
596578
prod,
597579
)?);
@@ -854,11 +836,10 @@ fn compute_active_features(
854836
pub fn make(
855837
filter: &Option<regex::Regex>,
856838
project_context: &ProjectContext,
857-
show_progress: bool,
858839
prod: bool,
859840
cli_features: Option<&Vec<String>>,
860841
) -> Result<AHashMap<String, Package>> {
861-
let mut map = read_packages(project_context, show_progress, prod)?;
842+
let mut map = read_packages(project_context, prod)?;
862843

863844
let active_features = compute_active_features(&map, cli_features, prod)?;
864845

‎rewatch/src/format.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn get_files_in_scope() -> Result<Vec<String>> {
3939
let project_context = project_context::ProjectContext::new(&current_dir)?;
4040

4141
// Format walks all source files regardless of feature selection.
42-
let packages = packages::make(&None, &project_context, false, false, None)?;
42+
let packages = packages::make(&None, &project_context, false, None)?;
4343
let mut files: Vec<String> = Vec::new();
4444
let packages_to_format = project_context.get_scoped_local_packages();
4545

‎rewatch/src/watcher.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ mod tests {
969969
std::fs::write(dependency.join("rescript.json"), r#"{"name":"#).unwrap();
970970

971971
let context = ProjectContext::new(&root).unwrap();
972-
let error = build::packages::make(&None, &context, false, false, None)
972+
let error = build::packages::make(&None, &context, false, None)
973973
.unwrap_err()
974974
.context("Could not initialize build");
975975
assert!(format!("{error:#}").contains("Failed to parse rescript.json"));
@@ -995,7 +995,7 @@ mod tests {
995995
assert!(paths.contains(&(dependency.clone(), RecursiveMode::Recursive)));
996996

997997
std::fs::write(dependency.join("rescript.json"), r#"{"name":"new-dependency"}"#).unwrap();
998-
let recovered = build::packages::make(&None, &context, false, false, None).unwrap();
998+
let recovered = build::packages::make(&None, &context, false, None).unwrap();
999999
assert!(recovered.contains_key("new-dependency"));
10001000
}
10011001

‎rewatch/tests/suite.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ fi
145145
./watch/05-watch-ignores-non-source.sh &&
146146
./watch/06-watch-missing-source-folder.sh &&
147147
./watch/07-changed-interface-after-failed-implementation.sh &&
148-
./watch/07-watch-recovers-from-invalid-config.sh &&
149-
./watch/08-watch-recovers-new-dependency-config.sh &&
148+
./watch/08-watch-recovers-from-invalid-config.sh &&
149+
./watch/09-watch-recovers-new-dependency-config.sh &&
150150

151151
# Lock tests
152152
./lock/01-lock-when-watching.sh &&

rewatch/tests/watch/07-watch-recovers-from-invalid-config.sh renamed to rewatch/tests/watch/08-watch-recovers-from-invalid-config.sh

File renamed without changes.

rewatch/tests/watch/08-watch-recovers-new-dependency-config.sh renamed to rewatch/tests/watch/09-watch-recovers-new-dependency-config.sh

File renamed without changes.

‎tests/build_tests/weird_deps/input.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ const out = await execBuild();
99
assert.notEqual(out.status, 0);
1010
assert.match(out.stderr, /could not build package tree/i);
1111
assert.match(out.stderr, /dependency 'weird'/i);
12+
assert.doesNotMatch(out.stdout, /error building package tree/i);
1213
await execClean();

0 commit comments

Comments
 (0)