diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2019-07-31 13:58:41 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-07-31 11:58:41 +0000 |
commit | 421cbd39b4f0fdbdfc2eeed6da8dd3410246a044 (patch) | |
tree | add5b11671f8275323ab9d159962a9065d5ff8aa /cli/compiler.rs | |
parent | ef63ec763a142f1e96e12e21d27ffae439f84ffd (diff) |
factor out FileFetcher to separate module (#2683)
* merge SourceFileFetcher trait and FileFetcher struct
* move logic related to source file fetching to //cli/file_fetcher.rs
* use Result when creating new ThreadSafeState
Diffstat (limited to 'cli/compiler.rs')
-rw-r--r-- | cli/compiler.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/cli/compiler.rs b/cli/compiler.rs index 0348c3478..f90337d02 100644 --- a/cli/compiler.rs +++ b/cli/compiler.rs @@ -1,9 +1,8 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -use crate::deno_dir::DenoDir; -use crate::deno_dir::SourceFile; -use crate::deno_dir::SourceFileFetcher; use crate::diagnostics::Diagnostic; use crate::disk_cache::DiskCache; +use crate::file_fetcher::SourceFile; +use crate::file_fetcher::SourceFileFetcher; use crate::msg; use crate::resources; use crate::source_maps::SourceMapGetter; @@ -160,7 +159,7 @@ fn load_config_file( } pub struct TsCompiler { - pub deno_dir: DenoDir, + pub file_fetcher: SourceFileFetcher, pub config: CompilerConfig, pub config_hash: Vec<u8>, pub disk_cache: DiskCache, @@ -174,7 +173,8 @@ pub struct TsCompiler { impl TsCompiler { pub fn new( - deno_dir: DenoDir, + file_fetcher: SourceFileFetcher, + disk_cache: DiskCache, use_disk_cache: bool, config_path: Option<String>, ) -> Self { @@ -189,8 +189,8 @@ impl TsCompiler { }; Self { - disk_cache: deno_dir.clone().gen_cache, - deno_dir, + file_fetcher, + disk_cache, config: compiler_config, config_hash: config_bytes, compiled: Mutex::new(HashSet::new()), @@ -474,7 +474,7 @@ impl TsCompiler { self.mark_compiled(module_specifier.as_url()); let source_file = self - .deno_dir + .file_fetcher .fetch_source_file(&module_specifier) .expect("Source file not found"); @@ -583,7 +583,7 @@ impl TsCompiler { script_name: &str, ) -> Option<SourceFile> { if let Some(module_specifier) = self.try_to_resolve(script_name) { - return match self.deno_dir.fetch_source_file(&module_specifier) { + return match self.file_fetcher.fetch_source_file(&module_specifier) { Ok(out) => Some(out), Err(_) => None, }; |