diff options
Diffstat (limited to 'cli/standalone')
-rw-r--r-- | cli/standalone/binary.rs | 4 | ||||
-rw-r--r-- | cli/standalone/mod.rs | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/cli/standalone/binary.rs b/cli/standalone/binary.rs index a3a12f5e2..2fc0c30c2 100644 --- a/cli/standalone/binary.rs +++ b/cli/standalone/binary.rs @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use std::borrow::Cow; use std::collections::BTreeMap; use std::env::current_exe; use std::ffi::OsString; @@ -240,7 +241,7 @@ pub fn is_standalone_binary(exe_path: &Path) -> bool { /// the bundle is executed. If not, this function exits with `Ok(None)`. pub fn extract_standalone( exe_path: &Path, - cli_args: Vec<OsString>, + cli_args: Cow<Vec<OsString>>, ) -> Result< Option<impl Future<Output = Result<(Metadata, eszip::EszipV2), AnyError>>>, AnyError, @@ -257,6 +258,7 @@ pub fn extract_standalone( file.seek(SeekFrom::Start(trailer.eszip_pos))?; + let cli_args = cli_args.into_owned(); // If we have an eszip, read it out Ok(Some(async move { let bufreader = diff --git a/cli/standalone/mod.rs b/cli/standalone/mod.rs index dde70f63a..043f05e13 100644 --- a/cli/standalone/mod.rs +++ b/cli/standalone/mod.rs @@ -319,7 +319,7 @@ impl RootCertStoreProvider for StandaloneRootCertStoreProvider { pub async fn run( mut eszip: eszip::EszipV2, metadata: Metadata, -) -> Result<(), AnyError> { +) -> Result<i32, AnyError> { let main_module = &metadata.entrypoint; let current_exe_path = std::env::current_exe().unwrap(); let current_exe_name = @@ -574,12 +574,14 @@ pub async fn run( false, ); + // Initialize v8 once from the main thread. v8_set_flags(construct_v8_flags(&[], &metadata.v8_flags, vec![])); + deno_core::JsRuntime::init_platform(None); let mut worker = worker_factory .create_main_worker(main_module.clone(), permissions) .await?; let exit_code = worker.run().await?; - std::process::exit(exit_code) + Ok(exit_code) } |