caught incorrect file ext

This commit is contained in:
Trevor Settles 2024-01-27 10:27:14 -07:00
parent 09d7157216
commit 579522a602
No known key found for this signature in database
GPG key ID: F46B83058222DBAA

View file

@ -714,6 +714,24 @@ pub fn standard_load_config(
}
}
pub fn is_valied_roc_file<'a>(path: PathBuf) -> Result<(), BuildFileError<'a>> {
let roc_ext = OsStr::new("roc");
match path.extension() {
Some(ext) => {
if roc_ext != ext {
Err(BuildFileError::LoadingProblem(
LoadingProblem::FormattedReport("It failed, wrong file ext".to_string()),
))
} else {
Ok(())
}
}
None => Err(BuildFileError::LoadingProblem(
LoadingProblem::FormattedReport("It failed, no file ext".to_string()),
)),
}
}
#[allow(clippy::too_many_arguments)]
pub fn build_file<'a>(
arena: &'a Bump,
@ -731,6 +749,8 @@ pub fn build_file<'a>(
) -> Result<BuiltFile<'a>, BuildFileError<'a>> {
let compilation_start = Instant::now();
is_valied_roc_file(app_module_path)?;
// Step 1: compile the app and generate the .o file
let loaded =
roc_load::load_and_monomorphize(arena, app_module_path.clone(), roc_cache_dir, load_config)