diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-01-31 22:15:22 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-01 03:15:22 +0000 |
commit | 4b7c6049ef9d40394eb823859c82cbf8d293430d (patch) | |
tree | 61e6de7c69c9d00faeef0ff7e6c223224a53de9e /test_util/src | |
parent | 830d096b66696ad9f4e67b3ed8460fb1ff7a9170 (diff) |
refactor: load bytes in deno_graph (#22212)
Upgrades deno_graph to 0.64 where deno_graph is now responsible for
turning bytes into a string. This is in preparation for Wasm modules.
Diffstat (limited to 'test_util/src')
-rw-r--r-- | test_util/src/fs.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/test_util/src/fs.rs b/test_util/src/fs.rs index 17620276b..0e47a7503 100644 --- a/test_util/src/fs.rs +++ b/test_util/src/fs.rs @@ -118,6 +118,10 @@ impl PathRef { .with_context(|| format!("Could not read file: {}", self)) } + pub fn read_to_bytes_if_exists(&self) -> Result<Vec<u8>, anyhow::Error> { + fs::read(self).with_context(|| format!("Could not read file: {}", self)) + } + pub fn read_json<TValue: DeserializeOwned>(&self) -> TValue { serde_json::from_str(&self.read_to_string()).unwrap() } |