Do not throw error for files not found in lib_dirs (#4029)

This commit is contained in:
Jakub Žádník 2021-09-20 21:44:47 +03:00 committed by GitHub
parent b3b3cf0689
commit 349af05da8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 13 deletions

View File

@ -69,13 +69,11 @@ pub fn source(args: CommandArgs) -> Result<OutputStream, ShellError> {
for lib_path in dir {
match lib_path {
Ok(name) => {
let path = canonicalize_with(&source_file, name).map_err(|e| {
ShellError::labeled_error(
format!("Can't load source file. Reason: {}", e.to_string()),
"Can't load this file",
filename.span(),
)
})?;
let path = if let Ok(p) = canonicalize_with(&source_file, name) {
p
} else {
continue;
};
if let Ok(contents) = std::fs::read_to_string(path) {
let result = script::run_script_standalone(contents, true, ctx, false);

View File

@ -61,12 +61,11 @@ fn find_source_file(
if let Some(dir) = lib_dirs {
for lib_path in dir.into_iter().flatten() {
let path = canonicalize_with(&file, lib_path).map_err(|e| {
ParseError::general_error(
format!("Can't load source file. Reason: {}", e.to_string()),
"Can't load this file".spanned(file_span),
)
})?;
let path = if let Ok(p) = canonicalize_with(&file, lib_path) {
p
} else {
continue;
};
if let Ok(contents) = std::fs::read_to_string(&path) {
return parse(&contents, 0, scope);