Skip to content

refactor: factor out SourceFileFetcher to separate module #2683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions cli/compiler.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand All @@ -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()),
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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,
};
Expand Down
Loading