mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 19:08:15 +00:00
refactor: move PackageJson to deno_config (#24348)
This commit is contained in:
parent
86e0292733
commit
0da01c0ca6
28 changed files with 509 additions and 871 deletions
|
@ -304,6 +304,35 @@ pub trait FileSystem: std::fmt::Debug + MaybeSend + MaybeSync {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct DenoConfigFsAdapter<'a>(&'a dyn FileSystem);
|
||||
|
||||
impl<'a> DenoConfigFsAdapter<'a> {
|
||||
pub fn new(fs: &'a dyn FileSystem) -> Self {
|
||||
Self(fs)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> deno_config::fs::DenoConfigFs for DenoConfigFsAdapter<'a> {
|
||||
fn read_to_string(&self, path: &Path) -> Result<String, std::io::Error> {
|
||||
use deno_io::fs::FsError;
|
||||
use std::io::ErrorKind;
|
||||
self
|
||||
.0
|
||||
.read_text_file_lossy_sync(path, None)
|
||||
.map_err(|err| match err {
|
||||
FsError::Io(io) => io,
|
||||
FsError::FileBusy => std::io::Error::new(ErrorKind::Other, "file busy"),
|
||||
FsError::NotSupported => {
|
||||
std::io::Error::new(ErrorKind::Other, "not supported")
|
||||
}
|
||||
FsError::PermissionDenied(name) => std::io::Error::new(
|
||||
ErrorKind::PermissionDenied,
|
||||
format!("requires {}", name),
|
||||
),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Like String::from_utf8_lossy but operates on owned values
|
||||
#[inline(always)]
|
||||
fn string_from_utf8_lossy(buf: Vec<u8>) -> String {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue