diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-09-30 09:33:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-30 13:33:32 +0000 |
commit | 69ab72002550b5797185b7651de28c700b220bb2 (patch) | |
tree | ce224c0631f42e3ad73e6bd848d1a597d19f1a9f /resolvers/deno/fs.rs | |
parent | c8f692057b256dac57342867b7606a74309449fc (diff) |
refactor: move ByonmNpmResolver to deno_resolver (#25937)
Some more slow progress on moving all the resolution code into
deno_resolver.
Diffstat (limited to 'resolvers/deno/fs.rs')
-rw-r--r-- | resolvers/deno/fs.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/resolvers/deno/fs.rs b/resolvers/deno/fs.rs new file mode 100644 index 000000000..b08be3798 --- /dev/null +++ b/resolvers/deno/fs.rs @@ -0,0 +1,27 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. + +use std::path::Path; +use std::path::PathBuf; + +pub struct DirEntry { + pub name: String, + pub is_file: bool, + pub is_directory: bool, +} + +pub trait DenoResolverFs { + fn read_to_string_lossy(&self, path: &Path) -> std::io::Result<String>; + fn realpath_sync(&self, path: &Path) -> std::io::Result<PathBuf>; + fn is_dir_sync(&self, path: &Path) -> bool; + fn read_dir_sync(&self, dir_path: &Path) -> std::io::Result<Vec<DirEntry>>; +} + +pub(crate) struct DenoPkgJsonFsAdapter<'a, Fs: DenoResolverFs>(pub &'a Fs); + +impl<'a, Fs: DenoResolverFs> deno_package_json::fs::DenoPkgJsonFs + for DenoPkgJsonFsAdapter<'a, Fs> +{ + fn read_to_string_lossy(&self, path: &Path) -> std::io::Result<String> { + self.0.read_to_string_lossy(path) + } +} |