diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-12-12 21:30:44 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-12 21:30:44 -0500 |
commit | 8972ebc9cc33ef1df21c899c35006ea712f7f91f (patch) | |
tree | 396e0aaf422b61e1a0c4c7a09a7bf84a84e7f459 /cli/tools/standalone.rs | |
parent | 8c026dab92b20fea44bc66f84db48b885c7264d1 (diff) |
fix: always derive http client from cli flags (#17029)
I'm not sure how to test this. It doesn't seem to have an existing test.
Closes #15921
Diffstat (limited to 'cli/tools/standalone.rs')
-rw-r--r-- | cli/tools/standalone.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/cli/tools/standalone.rs b/cli/tools/standalone.rs index c276119ea..558adc460 100644 --- a/cli/tools/standalone.rs +++ b/cli/tools/standalone.rs @@ -5,6 +5,7 @@ use crate::args::Flags; use crate::cache::DenoDir; use crate::graph_util::create_graph_and_maybe_check; use crate::graph_util::error_for_any_npm_specifier; +use crate::http_util::HttpClient; use crate::standalone::Metadata; use crate::standalone::MAGIC_TRAILER; use crate::util::path::path_has_trailing_slash; @@ -18,7 +19,6 @@ use deno_core::serde_json; use deno_core::url::Url; use deno_graph::ModuleSpecifier; use deno_runtime::colors; -use deno_runtime::deno_fetch::reqwest::Client; use deno_runtime::permissions::Permissions; use std::env; use std::fs; @@ -64,7 +64,8 @@ pub async fn compile( // Select base binary based on target let original_binary = - get_base_binary(deno_dir, compile_flags.target.clone()).await?; + get_base_binary(&ps.http_client, deno_dir, compile_flags.target.clone()) + .await?; let final_bin = create_standalone_binary( original_binary, @@ -82,6 +83,7 @@ pub async fn compile( } async fn get_base_binary( + client: &HttpClient, deno_dir: &DenoDir, target: Option<String>, ) -> Result<Vec<u8>, AnyError> { @@ -103,7 +105,8 @@ async fn get_base_binary( let binary_path = download_directory.join(&binary_path_suffix); if !binary_path.exists() { - download_base_binary(&download_directory, &binary_path_suffix).await?; + download_base_binary(client, &download_directory, &binary_path_suffix) + .await?; } let archive_data = tokio::fs::read(binary_path).await?; @@ -114,14 +117,12 @@ async fn get_base_binary( } async fn download_base_binary( + client: &HttpClient, output_directory: &Path, binary_path_suffix: &str, ) -> Result<(), AnyError> { let download_url = format!("https://dl.deno.land/{}", binary_path_suffix); - let client_builder = Client::builder(); - let client = client_builder.build()?; - log::info!("Checking {}", &download_url); let res = client.get(&download_url).send().await?; |