refactor: use of lock file in ModuleGraph2 (#8087)

This commit is contained in:
Bartek Iwańczuk 2020-10-23 23:01:54 +02:00 committed by GitHub
parent 8d95bd15e1
commit 35f184cdcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 29 deletions

View file

@ -48,7 +48,7 @@ pub struct ProgramState {
pub dir: deno_dir::DenoDir,
pub file_fetcher: SourceFileFetcher,
pub ts_compiler: TsCompiler,
pub lockfile: Option<Mutex<Lockfile>>,
pub lockfile: Option<Arc<Mutex<Lockfile>>>,
pub maybe_import_map: Option<ImportMap>,
pub maybe_inspector_server: Option<Arc<InspectorServer>>,
}
@ -78,7 +78,7 @@ impl ProgramState {
let lockfile = if let Some(filename) = &flags.lock {
let lockfile = Lockfile::new(filename.clone(), flags.lock_write)?;
Some(Mutex::new(lockfile))
Some(Arc::new(Mutex::new(lockfile)))
} else {
None
};
@ -128,9 +128,10 @@ impl ProgramState {
let specifier = specifier.clone();
let handler =
Rc::new(RefCell::new(FetchHandler::new(self, dynamic_permissions)?));
let mut builder = GraphBuilder2::new(handler, maybe_import_map);
let mut builder =
GraphBuilder2::new(handler, maybe_import_map, self.lockfile.clone());
builder.add(&specifier, is_dynamic).await?;
let mut graph = builder.get_graph(&self.lockfile);
let mut graph = builder.get_graph();
let debug = self.flags.log_level == Some(log::Level::Debug);
let maybe_config_path = self.flags.config_path.clone();