mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 04:39:10 +00:00
refactor(npm): extract out some npm fs resolution code from the cli (#27607)
Moves the npm fs resolvers into the deno_resolution crate. This does not entirely move things out, but is a step in that direction.
This commit is contained in:
parent
ce0968ef3a
commit
093f3ba565
24 changed files with 312 additions and 213 deletions
|
@ -6,7 +6,6 @@ use std::path::Path;
|
|||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Error as AnyError;
|
||||
use deno_cache_dir::file_fetcher::CacheSetting;
|
||||
use deno_cache_dir::npm::NpmCacheDir;
|
||||
use deno_error::JsErrorBox;
|
||||
|
@ -51,7 +50,7 @@ pub use tarball::TarballCache;
|
|||
#[class(generic)]
|
||||
pub struct DownloadError {
|
||||
pub status_code: Option<StatusCode>,
|
||||
pub error: AnyError,
|
||||
pub error: JsErrorBox,
|
||||
}
|
||||
|
||||
impl std::error::Error for DownloadError {
|
||||
|
@ -312,15 +311,17 @@ impl<
|
|||
&self,
|
||||
name: &str,
|
||||
package_info: &NpmPackageInfo,
|
||||
) -> Result<(), AnyError> {
|
||||
) -> Result<(), JsErrorBox> {
|
||||
let file_cache_path = self.get_registry_package_info_file_cache_path(name);
|
||||
let file_text = serde_json::to_string(&package_info)?;
|
||||
let file_text =
|
||||
serde_json::to_string(&package_info).map_err(JsErrorBox::from_err)?;
|
||||
atomic_write_file_with_retries(
|
||||
&self.sys,
|
||||
&file_cache_path,
|
||||
file_text.as_bytes(),
|
||||
0o644,
|
||||
)?;
|
||||
)
|
||||
.map_err(JsErrorBox::from_err)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue