diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-11-29 09:32:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-29 09:32:23 -0500 |
commit | 9ac405d587ca1465debd4a65a09324b7a6b2c04f (patch) | |
tree | b3cc4adb3ddf06dc5d380c39f9e8a82c24b25655 /cli/standalone/virtual_fs.rs | |
parent | 7e56a0466fc9964ca5dd3533bb65c00cd1bac4dc (diff) |
feat(compile): support "bring your own node_modules" in deno compile (#21377)
Not tested thoroughly. This is a good start.
Closes #21350
Diffstat (limited to 'cli/standalone/virtual_fs.rs')
-rw-r--r-- | cli/standalone/virtual_fs.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/cli/standalone/virtual_fs.rs b/cli/standalone/virtual_fs.rs index c96aed143..ee870611b 100644 --- a/cli/standalone/virtual_fs.rs +++ b/cli/standalone/virtual_fs.rs @@ -92,9 +92,7 @@ impl VfsBuilder { if file_type.is_dir() { self.add_dir_recursive_internal(&path)?; } else if file_type.is_file() { - let file_bytes = std::fs::read(&path) - .with_context(|| format!("Reading {}", path.display()))?; - self.add_file(&path, file_bytes)?; + self.add_file_at_path(&path)?; } else if file_type.is_symlink() { let target = util::fs::canonicalize_path(&path) .with_context(|| format!("Reading symlink {}", path.display()))?; @@ -163,6 +161,12 @@ impl VfsBuilder { Ok(current_dir) } + pub fn add_file_at_path(&mut self, path: &Path) -> Result<(), AnyError> { + let file_bytes = std::fs::read(path) + .with_context(|| format!("Reading {}", path.display()))?; + self.add_file(path, file_bytes) + } + fn add_file(&mut self, path: &Path, data: Vec<u8>) -> Result<(), AnyError> { log::debug!("Adding file '{}'", path.display()); let checksum = util::checksum::gen(&[&data]); |