forked from extern/nushell
Fix test failure
This commit is contained in:
parent
8f78995014
commit
d07a3928b2
@ -226,36 +226,43 @@ pub fn fetch(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cwd.push(Path::new(location));
|
cwd.push(Path::new(location));
|
||||||
let cwd = dunce::canonicalize(cwd).unwrap();
|
if let Ok(cwd) = dunce::canonicalize(cwd) {
|
||||||
match std::fs::read(&cwd) {
|
match std::fs::read(&cwd) {
|
||||||
Ok(bytes) => match std::str::from_utf8(&bytes) {
|
Ok(bytes) => match std::str::from_utf8(&bytes) {
|
||||||
Ok(s) => Ok((
|
Ok(s) => Ok((
|
||||||
cwd.extension()
|
cwd.extension()
|
||||||
.map(|name| name.to_string_lossy().to_string()),
|
.map(|name| name.to_string_lossy().to_string()),
|
||||||
Value::string(s),
|
Value::string(s),
|
||||||
Tag {
|
Tag {
|
||||||
|
span,
|
||||||
|
origin: Some(Uuid::new_v4()),
|
||||||
|
},
|
||||||
|
SpanSource::File(cwd.to_string_lossy().to_string()),
|
||||||
|
)),
|
||||||
|
Err(_) => Ok((
|
||||||
|
None,
|
||||||
|
Value::Binary(bytes),
|
||||||
|
Tag {
|
||||||
|
span,
|
||||||
|
origin: Some(Uuid::new_v4()),
|
||||||
|
},
|
||||||
|
SpanSource::File(cwd.to_string_lossy().to_string()),
|
||||||
|
)),
|
||||||
|
},
|
||||||
|
Err(_) => {
|
||||||
|
return Err(ShellError::labeled_error(
|
||||||
|
"File could not be opened",
|
||||||
|
"file not found",
|
||||||
span,
|
span,
|
||||||
origin: Some(Uuid::new_v4()),
|
));
|
||||||
},
|
}
|
||||||
SpanSource::File(cwd.to_string_lossy().to_string()),
|
|
||||||
)),
|
|
||||||
Err(_) => Ok((
|
|
||||||
None,
|
|
||||||
Value::Binary(bytes),
|
|
||||||
Tag {
|
|
||||||
span,
|
|
||||||
origin: Some(Uuid::new_v4()),
|
|
||||||
},
|
|
||||||
SpanSource::File(cwd.to_string_lossy().to_string()),
|
|
||||||
)),
|
|
||||||
},
|
|
||||||
Err(_) => {
|
|
||||||
return Err(ShellError::labeled_error(
|
|
||||||
"File could not be opened",
|
|
||||||
"file not found",
|
|
||||||
span,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return Err(ShellError::labeled_error(
|
||||||
|
"File could not be opened",
|
||||||
|
"file not found",
|
||||||
|
span,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user