diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/lib.rs | 3 | ||||
-rw-r--r-- | cli/ops/compiler.rs | 8 | ||||
-rw-r--r-- | cli/state.rs | 13 | ||||
-rw-r--r-- | cli/tests/054_info_local_imports.out | 9 | ||||
-rw-r--r-- | cli/tests/integration_tests.rs | 6 |
5 files changed, 25 insertions, 14 deletions
diff --git a/cli/lib.rs b/cli/lib.rs index 6fba5bda8..3b174bb75 100644 --- a/cli/lib.rs +++ b/cli/lib.rs @@ -205,7 +205,6 @@ async fn print_file_info( eprintln!("\n{}", e.to_string()); std::process::exit(1); } - let compiled = maybe_compiled.unwrap(); if out.media_type == msg::MediaType::TypeScript || (out.media_type == msg::MediaType::JavaScript && global_state_.ts_compiler.compile_js) @@ -235,7 +234,7 @@ async fn print_file_info( } let isolate = worker.isolate.try_lock().unwrap(); - if let Some(deps) = isolate.modules.deps(&compiled.name) { + if let Some(deps) = isolate.modules.deps(&module_specifier) { println!("{}{}", colors::bold("deps:\n".to_string()), deps.name); if let Some(ref depsdeps) = deps.deps { for d in depsdeps { diff --git a/cli/ops/compiler.rs b/cli/ops/compiler.rs index 2d0ffe1f3..d2a2a1d58 100644 --- a/cli/ops/compiler.rs +++ b/cli/ops/compiler.rs @@ -58,11 +58,6 @@ fn op_resolve_modules( _data: Option<ZeroCopyBuf>, ) -> Result<JsonOp, ErrBox> { let args: SpecifiersReferrerArgs = serde_json::from_value(args)?; - - // TODO(ry) Maybe a security hole. Only the compiler worker should have access - // to this. Need a test to demonstrate the hole. - let is_dyn_import = false; - let (referrer, is_main) = if let Some(referrer) = args.referrer { (referrer, false) } else { @@ -72,8 +67,7 @@ fn op_resolve_modules( let mut specifiers = vec![]; for specifier in &args.specifiers { - let resolved_specifier = - state.resolve(specifier, &referrer, is_main, is_dyn_import); + let resolved_specifier = state.resolve(specifier, &referrer, is_main); match resolved_specifier { Ok(ms) => specifiers.push(ms.as_str().to_owned()), Err(err) => return Err(err), diff --git a/cli/state.rs b/cli/state.rs index 6f3f0a4c7..b224451c5 100644 --- a/cli/state.rs +++ b/cli/state.rs @@ -167,7 +167,6 @@ impl Loader for ThreadSafeState { specifier: &str, referrer: &str, is_main: bool, - is_dyn_import: bool, ) -> Result<ModuleSpecifier, ErrBox> { if !is_main { if let Some(import_map) = &self.import_map { @@ -180,10 +179,6 @@ impl Loader for ThreadSafeState { let module_specifier = ModuleSpecifier::resolve_import(specifier, referrer)?; - if is_dyn_import { - self.check_dyn_import(&module_specifier)?; - } - Ok(module_specifier) } @@ -192,7 +187,15 @@ impl Loader for ThreadSafeState { &self, module_specifier: &ModuleSpecifier, maybe_referrer: Option<ModuleSpecifier>, + is_dyn_import: bool, ) -> Pin<Box<deno_core::SourceCodeInfoFuture>> { + if is_dyn_import { + if let Err(e) = self.check_dyn_import(&module_specifier) { + return async move { Err(e) }.boxed(); + } + } + + // TODO(bartlomieju): incrementing resolve_count here has no sense... self.metrics.resolve_count.fetch_add(1, Ordering::SeqCst); let module_url_specified = module_specifier.to_string(); let fut = self diff --git a/cli/tests/054_info_local_imports.out b/cli/tests/054_info_local_imports.out new file mode 100644 index 000000000..9794e4ede --- /dev/null +++ b/cli/tests/054_info_local_imports.out @@ -0,0 +1,9 @@ +local: [WILDCARD]005_more_imports.ts +type: TypeScript +compiled: [WILDCARD]005_more_imports.ts.js +map: [WILDCARD]005_more_imports.ts.js.map +deps: +file://[WILDCARD]/005_more_imports.ts + └─┬ file://[WILDCARD]/subdir/mod1.ts + └─┬ file://[WILDCARD]/subdir/subdir2/mod2.ts + └── file://[WILDCARD]/subdir/print_hello.ts diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 3e5073b45..260ded177 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -385,6 +385,12 @@ itest!(_052_no_remote_flag { http_server: true, }); +itest!(_054_info_local_imports { + args: "info 005_more_imports.ts", + output: "054_info_local_imports.out", + exit_code: 0, +}); + itest!(lock_check_ok { args: "run --lock=lock_check_ok.json http://127.0.0.1:4545/cli/tests/003_relative_import.ts", output: "003_relative_import.ts.out", |