summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2020-09-30 17:22:58 +1000
committerGitHub <noreply@github.com>2020-09-30 17:22:58 +1000
commit7c62b7b0434314fee1355ccfa2a95aea2a9cc01e (patch)
tree483f3de1adf3f209d256b1f4af4d22e16d7732da
parent27ee4b255107d8e074c06b57927b7349f4edd044 (diff)
fix(cli): use global_state file_fetcher when using SpecifierHandler (#7748)
Fixes: #7709
-rw-r--r--cli/global_state.rs4
-rw-r--r--cli/specifier_handler.rs26
-rw-r--r--cli/tests/integration_tests.rs6
3 files changed, 19 insertions, 17 deletions
diff --git a/cli/global_state.rs b/cli/global_state.rs
index ec2d78130..336dcae00 100644
--- a/cli/global_state.rs
+++ b/cli/global_state.rs
@@ -126,8 +126,10 @@ impl GlobalState {
if self.flags.no_check {
debug!("Transpiling root: {}", module_specifier);
+ // TODO(kitsonk) note that self.permissions != permissions, which is
+ // something that should be handled better in the future.
let handler =
- Rc::new(RefCell::new(FetchHandler::new(&self.flags, &permissions)?));
+ Rc::new(RefCell::new(FetchHandler::new(self, permissions.clone())?));
let mut builder = GraphBuilder::new(handler, maybe_import_map);
builder.insert(&module_specifier).await?;
let mut graph = builder.get_graph(&self.lockfile)?;
diff --git a/cli/specifier_handler.rs b/cli/specifier_handler.rs
index f2b422141..bc5b29e4e 100644
--- a/cli/specifier_handler.rs
+++ b/cli/specifier_handler.rs
@@ -4,8 +4,7 @@ use crate::deno_dir::DenoDir;
use crate::disk_cache::DiskCache;
use crate::file_fetcher::SourceFileFetcher;
use crate::file_fetcher::TextDocument;
-use crate::flags::Flags;
-use crate::http_cache::HttpCache;
+use crate::global_state::GlobalState;
use crate::media_type::MediaType;
use crate::permissions::Permissions;
@@ -22,6 +21,7 @@ use std::error::Error;
use std::fmt;
use std::pin::Pin;
use std::result;
+use std::sync::Arc;
type Result<V> = result::Result<V, AnyError>;
@@ -204,27 +204,19 @@ pub struct FetchHandler {
}
impl FetchHandler {
- pub fn new(flags: &Flags, permissions: &Permissions) -> Result<Self> {
+ pub fn new(
+ global_state: &Arc<GlobalState>,
+ permissions: Permissions,
+ ) -> Result<Self> {
let custom_root = env::var("DENO_DIR").map(String::into).ok();
let deno_dir = DenoDir::new(custom_root)?;
- let deps_cache_location = deno_dir.root.join("deps");
- let http_cache = HttpCache::new(&deps_cache_location);
- let ca_file = flags.ca_file.clone().or_else(|| env::var("DENO_CERT").ok());
-
- let file_fetcher = SourceFileFetcher::new(
- http_cache,
- !flags.reload,
- flags.cache_blocklist.clone(),
- flags.no_remote,
- flags.cached_only,
- ca_file.as_deref(),
- )?;
let disk_cache = deno_dir.gen_cache;
+ let file_fetcher = global_state.file_fetcher.clone();
Ok(FetchHandler {
disk_cache,
file_fetcher,
- permissions: permissions.clone(),
+ permissions,
})
}
}
@@ -387,6 +379,8 @@ impl SpecifierHandler for FetchHandler {
pub mod tests {
use super::*;
+ use crate::http_cache::HttpCache;
+
use deno_core::futures::future;
use std::fs;
use std::path::PathBuf;
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index c062d3371..d836bc71a 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -1506,6 +1506,12 @@ itest!(deno_test_only {
output: "deno_test_only.ts.out",
});
+itest!(deno_test_no_check {
+ args: "test --no-check test_runner_test.ts",
+ exit_code: 1,
+ output: "deno_test.out",
+});
+
#[test]
fn timeout_clear() {
// https://github.com/denoland/deno/issues/7599