refactor: NpmRegistryApi - #[async_trait(?Send)] (#24126)

This commit is contained in:
David Sherret 2024-06-06 18:37:41 -04:00 committed by GitHub
parent 47d19461a5
commit 7a17eba5a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 37 additions and 31 deletions

View file

@ -83,26 +83,31 @@ pub async fn create_managed_npm_resolver_for_lsp(
) -> Arc<dyn CliNpmResolver> {
let npm_cache = create_cache(&options);
let npm_api = create_api(&options, npm_cache.clone());
let snapshot = match resolve_snapshot(&npm_api, options.snapshot).await {
Ok(snapshot) => snapshot,
Err(err) => {
log::warn!("failed to resolve snapshot: {}", err);
None
}
};
create_inner(
options.fs,
options.http_client_provider,
options.maybe_lockfile,
npm_api,
npm_cache,
options.npmrc,
options.package_json_installer,
options.text_only_progress_bar,
options.maybe_node_modules_path,
options.npm_system_info,
snapshot,
)
// spawn due to the lsp's `Send` requirement
deno_core::unsync::spawn(async move {
let snapshot = match resolve_snapshot(&npm_api, options.snapshot).await {
Ok(snapshot) => snapshot,
Err(err) => {
log::warn!("failed to resolve snapshot: {}", err);
None
}
};
create_inner(
options.fs,
options.http_client_provider,
options.maybe_lockfile,
npm_api,
npm_cache,
options.npmrc,
options.package_json_installer,
options.text_only_progress_bar,
options.maybe_node_modules_path,
options.npm_system_info,
snapshot,
)
})
.await
.unwrap()
}
pub async fn create_managed_npm_resolver(