Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ pub struct Flags {
pub eszip: bool,
pub node_conditions: Vec<String>,
pub preload: Vec<String>,
pub connected: bool,
pub tunnel: bool,
}

#[derive(Clone, Debug, Eq, PartialEq, Default, Serialize, Deserialize)]
Expand Down Expand Up @@ -3370,7 +3370,7 @@ fn run_args(command: Command, top_level: bool) -> Command {
.arg(env_file_arg())
.arg(no_code_cache_arg())
.arg(coverage_arg())
.arg(connected_arg())
.arg(tunnel_arg())
}

fn run_subcommand() -> Command {
Expand Down Expand Up @@ -3447,7 +3447,7 @@ Start a server defined in server.ts, watching for changes and running on port 50
)
.arg(env_file_arg())
.arg(no_code_cache_arg())
.arg(connected_arg())
.arg(tunnel_arg())
}

fn task_subcommand() -> Command {
Expand Down Expand Up @@ -3500,7 +3500,7 @@ Evaluate a task from string:
).action(ArgAction::SetTrue)
)
.arg(node_modules_dir_arg())
.arg(connected_arg())
.arg(tunnel_arg())
})
}

Expand Down Expand Up @@ -4643,9 +4643,11 @@ fn no_check_arg() -> Arg {
.help_heading(TYPE_CHECKING_HEADING)
}

fn connected_arg() -> Arg {
Arg::new("connected")
.long("connected")
fn tunnel_arg() -> Arg {
Arg::new("tunnel")
.long("tunnel")
.alias("connected")
.short('t')
.hide(true)
.num_args(0..=1)
.require_equals(true)
Expand Down Expand Up @@ -5748,7 +5750,7 @@ fn run_parse(
runtime_args_parse(flags, matches, true, true, true)?;
ext_arg_parse(flags, matches);

flags.connected = matches.get_flag("connected");
flags.tunnel = matches.get_flag("tunnel");
flags.code_cache_enabled = !matches.get_flag("no-code-cache");
let coverage_dir = matches.remove_one::<String>("coverage");

Expand Down Expand Up @@ -5820,7 +5822,7 @@ fn serve_parse(
}
flags.code_cache_enabled = !matches.get_flag("no-code-cache");

flags.connected = matches.get_flag("connected");
flags.tunnel = matches.get_flag("tunnel");

let mut script_arg =
matches.remove_many::<String>("script_arg").ok_or_else(|| {
Expand Down Expand Up @@ -5873,7 +5875,7 @@ fn task_parse(
None
};

flags.connected = matches.get_flag("connected");
flags.tunnel = matches.get_flag("tunnel");

let mut task_flags = TaskFlags {
cwd: matches.remove_one::<String>("cwd"),
Expand Down
14 changes: 9 additions & 5 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,11 @@ async fn resolve_flags_and_init(
load_env_variables_from_env_files(env_file_paths.as_ref(), flags.log_level);

if deno_lib::args::has_flag_env_var("DENO_CONNECTED") {
flags.connected = true;
flags.tunnel = true;
}

// Tunnel sets up env vars and OTEL, so connect before everything else.
if flags.connected {
if flags.tunnel {
if let Err(err) = initialize_tunnel(&flags).await {
exit_for_error(err.context("Failed to start with --connected"));
}
Expand Down Expand Up @@ -914,9 +914,9 @@ async fn auth_tunnel(
) -> Result<String, deno_core::anyhow::Error> {
let mut args = vec!["deploy".to_string(), "tunnel-login".to_string()];

if let Some(token) = env_token {
if let Some(token) = &env_token {
args.push("--token".to_string());
args.push(token);
args.push(token.clone());
}

let mut child = tokio::process::Command::new(env::current_exe()?)
Expand All @@ -928,7 +928,11 @@ async fn auth_tunnel(
deno_runtime::exit(1);
}

Ok(tools::deploy::get_token_entry()?.get_password()?)
if let Some(token) = env_token {
Ok(token)
} else {
Ok(tools::deploy::get_token_entry()?.get_password()?)
}
}

#[allow(clippy::print_stderr)]
Expand Down
2 changes: 1 addition & 1 deletion cli/tools/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub async fn execute_script(
let progress_bar = factory.text_only_progress_bar();
let mut env_vars = task_runner::real_env_vars();

if flags.connected {
if flags.tunnel {
env_vars.insert("DENO_CONNECTED".into(), "1".into());
}

Expand Down
Loading