Skip to content

Commit ad6e0c9

Browse files
committed
Add more meaningful error when rescript.json is not found.
1 parent 8be72cc commit ad6e0c9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

rewatch/src/build/clean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn clean_source_files(build_state: &BuildState, root_package: &packages::Package
6767
SourceType::SourceFile(source_file) => {
6868
let package = build_state.packages.get(&module.package_name).unwrap_or_else(|| {
6969
panic!(
70-
"Could not find package for \"{}\" in build state",
70+
"Could not find package for \"{}\" in build state.\nMaybe you forgot to add the relative path to your root rescript.config.json file?",
7171
&module.package_name
7272
)
7373
});

rewatch/src/build/packages.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,13 @@ pub fn read_config(package_dir: &Path) -> Result<config::Config> {
244244

245245
if Path::new(&rescript_json_path).exists() {
246246
config::Config::new(&rescript_json_path)
247-
} else {
247+
} else if Path::new(&bsconfig_json_path).exists() {
248248
config::Config::new(&bsconfig_json_path)
249+
} else {
250+
Err(anyhow!(
251+
"Could not find rescript.json or bsconfig.json in package directory: {}",
252+
package_dir.to_string_lossy()
253+
))
249254
}
250255
}
251256

0 commit comments

Comments
 (0)