diff options
author | Takahiko Inayama <sagittariusm25@gmail.com> | 2020-07-07 20:05:28 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-07 13:05:28 +0200 |
commit | 14a44464a6e2c078fd329c26eff2ecfbc9b58603 (patch) | |
tree | 236bd6af3f692f56c5c34fd7f7449de9e9e7a005 /cli/tsc.rs | |
parent | 61d9952ff93d8dff26f6f3adb955affe09a951bc (diff) |
feat: add lockfile support to bundle (#6624)
Diffstat (limited to 'cli/tsc.rs')
-rw-r--r-- | cli/tsc.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/cli/tsc.rs b/cli/tsc.rs index 0d61e2e72..9f8216e52 100644 --- a/cli/tsc.rs +++ b/cli/tsc.rs @@ -625,6 +625,28 @@ impl TsCompiler { .add_to_graph(&module_specifier, None) .await?; let module_graph = module_graph_loader.get_graph(); + let module_graph_files = module_graph.values().collect::<Vec<_>>(); + // Check integrity of every file in module graph + if let Some(ref lockfile) = global_state.lockfile { + let mut g = lockfile.lock().unwrap(); + + for graph_file in &module_graph_files { + let check_passed = + g.check_or_insert(&graph_file.url, &graph_file.source_code); + + if !check_passed { + eprintln!( + "Subresource integrity check failed --lock={}\n{}", + g.filename, graph_file.url + ); + std::process::exit(10); + } + } + } + if let Some(ref lockfile) = global_state.lockfile { + let g = lockfile.lock().unwrap(); + g.write()?; + } let module_graph_json = serde_json::to_value(module_graph).expect("Failed to serialize data"); |