summaryrefslogtreecommitdiff
path: root/cli/worker.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/worker.rs')
-rw-r--r--cli/worker.rs26
1 files changed, 20 insertions, 6 deletions
diff --git a/cli/worker.rs b/cli/worker.rs
index b119c3b0d..d1238df41 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -1,6 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-use crate::colors;
use crate::inspector::DenoInspector;
use crate::inspector::InspectorServer;
use crate::inspector::InspectorSession;
@@ -8,7 +7,6 @@ use crate::js;
use crate::metrics::Metrics;
use crate::ops;
use crate::permissions::Permissions;
-use crate::version;
use deno_core::error::AnyError;
use deno_core::futures::future::poll_fn;
use deno_core::futures::future::FutureExt;
@@ -42,10 +40,12 @@ pub struct MainWorker {
pub struct WorkerOptions {
pub apply_source_maps: bool,
+ /// Sets `Deno.args` in JS runtime.
pub args: Vec<String>,
pub debug_flag: bool,
pub unstable: bool,
pub ca_filepath: Option<String>,
+ pub user_agent: String,
pub seed: Option<u64>,
pub module_loader: Rc<dyn ModuleLoader>,
// Callback that will be invoked when creating new instance
@@ -55,6 +55,12 @@ pub struct WorkerOptions {
pub attach_inspector: bool,
pub maybe_inspector_server: Option<Arc<InspectorServer>>,
pub should_break_on_first_statement: bool,
+ /// Sets `Deno.version.deno` in JS runtime.
+ pub runtime_version: String,
+ /// Sets `Deno.version.typescript` in JS runtime.
+ pub ts_version: String,
+ /// Sets `Deno.noColor` in JS runtime.
+ pub no_color: bool,
}
impl MainWorker {
@@ -128,7 +134,11 @@ impl MainWorker {
ops::signal::init(js_runtime);
ops::tls::init(js_runtime);
ops::tty::init(js_runtime);
- ops::websocket::init(js_runtime, options.ca_filepath.as_deref());
+ ops::websocket::init(
+ js_runtime,
+ options.ca_filepath.as_deref(),
+ options.user_agent.clone(),
+ );
}
{
let op_state = js_runtime.op_state();
@@ -154,12 +164,12 @@ impl MainWorker {
"args": options.args,
"applySourceMaps": options.apply_source_maps,
"debugFlag": options.debug_flag,
- "denoVersion": version::deno(),
- "noColor": !colors::use_color(),
+ "denoVersion": options.runtime_version,
+ "noColor": options.no_color,
"pid": std::process::id(),
"ppid": ops::runtime::ppid(),
"target": env!("TARGET"),
- "tsVersion": version::TYPESCRIPT,
+ "tsVersion": options.ts_version,
"unstableFlag": options.unstable,
"v8Version": deno_core::v8_version(),
});
@@ -249,6 +259,7 @@ mod tests {
let options = WorkerOptions {
apply_source_maps: false,
+ user_agent: "x".to_string(),
args: vec![],
debug_flag: false,
unstable: false,
@@ -260,6 +271,9 @@ mod tests {
maybe_inspector_server: None,
should_break_on_first_statement: false,
module_loader: Rc::new(deno_core::FsModuleLoader),
+ runtime_version: "x".to_string(),
+ ts_version: "x".to_string(),
+ no_color: true,
};
MainWorker::from_options(main_module, permissions, &options)