diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-03-20 14:05:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-20 14:05:13 -0400 |
commit | cd53ab5427811bddbed1c30d3733e1df87bb23f9 (patch) | |
tree | 0e2ea8e1b45f2d1d4acd20b666ae1d52d40940c6 /cli/worker.rs | |
parent | d78db7c0910aded010c2faee9a8c0f128f513985 (diff) |
refactor(ext/node): untangle dependencies between js files (#18284)
Moving some code around in `ext/node` is it's a bit better well defined
and makes it possible for others to embed it.
I expect to see no difference in startup perf with this change.
Diffstat (limited to 'cli/worker.rs')
-rw-r--r-- | cli/worker.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/cli/worker.rs b/cli/worker.rs index 2d467e01d..c505516a0 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -301,10 +301,8 @@ impl CliMainWorker { } fn initialize_main_module_for_node(&mut self) -> Result<(), AnyError> { - deno_node::initialize_runtime( - &mut self.worker.js_runtime, - self.ps.options.has_node_modules_dir(), - )?; + let mut maybe_binary_command_name = None; + if let DenoSubcommand::Run(flags) = self.ps.options.sub_command() { if let Ok(pkg_ref) = NpmPackageReqReference::from_str(&flags.script) { // if the user ran a binary command, we'll need to set process.argv[0] @@ -313,12 +311,16 @@ impl CliMainWorker { .sub_path .as_deref() .unwrap_or(pkg_ref.req.name.as_str()); - deno_node::initialize_binary_command( - &mut self.worker.js_runtime, - binary_name, - )?; + maybe_binary_command_name = Some(binary_name.to_string()); } } + + deno_node::initialize_runtime( + &mut self.worker.js_runtime, + self.ps.options.has_node_modules_dir(), + maybe_binary_command_name, + )?; + Ok(()) } @@ -627,6 +629,7 @@ fn create_web_worker_pre_execute_module_callback( deno_node::initialize_runtime( &mut worker.js_runtime, ps.options.has_node_modules_dir(), + None, )?; } |