Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ atty = "=0.2.14"
base64 = "=0.13.0"
cache_control = "=0.2.0"
chrono = "=0.4.19"
clap = "=3.1.6"
clap = { version = "=3.1.6", features = ["env"] }
clap_complete = "=3.1.1"
clap_complete_fig = "=3.1.4"
data-url = "=0.1.1"
Expand Down
18 changes: 11 additions & 7 deletions cli/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use deno_runtime::permissions::PermissionsOptions;
use log::debug;
use log::Level;
use once_cell::sync::Lazy;
use std::env;
use std::net::SocketAddr;
use std::num::NonZeroU32;
use std::num::NonZeroU8;
Expand Down Expand Up @@ -474,6 +475,8 @@ static ENV_VARIABLES_HELP: &str = r#"ENVIRONMENT VARIABLES:
DENO_DIR Set the cache directory
DENO_INSTALL_ROOT Set deno install's output directory
(defaults to $HOME/.deno/bin)
DENO_NO_PROMPT Set to disable permission prompts on access
(alternative to passing --no-prompt on invocation)
DENO_WEBGPU_TRACE Directory to use for wgpu traces
HTTP_PROXY Proxy address for HTTP requests
(module downloads, fetch)
Expand Down Expand Up @@ -1679,7 +1682,7 @@ fn compile_args_without_no_check(app: Command) -> Command {
}

fn permission_args(app: Command) -> Command {
app
let app = app
.arg(
Arg::new("allow-read")
.long("allow-read")
Expand Down Expand Up @@ -1760,12 +1763,13 @@ fn permission_args(app: Command) -> Command {
)
.arg(Arg::new("prompt").long("prompt").hide(true).help(
"deprecated: Fallback to prompt if required permission wasn't passed",
))
.arg(
Arg::new("no-prompt")
.long("no-prompt")
.help("Always throw if required permission wasn't passed"),
)
));
let no_prompt_arg = Arg::new("no-prompt")
.long("no-prompt")
.help("Always throw if required permission wasn't passed");
#[cfg(not(test))]
let no_prompt_arg = no_prompt_arg.env("DENO_NO_PROMPT");
app.arg(no_prompt_arg)
}

fn runtime_args(
Expand Down
20 changes: 20 additions & 0 deletions cli/tests/integration/run_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2685,3 +2685,23 @@ itest!(future_check2 {
output: "future_check2.out",
envs: vec![("DENO_FUTURE_CHECK".to_string(), "1".to_string())],
});

itest!(no_prompt_flag {
args: "run --quiet --unstable --no-prompt no_prompt.ts",
output_str: Some(""),
});

#[test]
fn deno_no_prompt_environment_variable() {
let output = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("run")
.arg("--unstable")
.arg("no_prompt.ts")
.env("DENO_NO_PROMPT", "1")
.spawn()
.unwrap()
.wait_with_output()
.unwrap();
assert!(output.status.success());
}
10 changes: 10 additions & 0 deletions cli/tests/testdata/no_prompt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
new Worker("data:,setTimeout(() => Deno.exit(2), 200)", {
type: "module",
deno: { namespace: true },
});

try {
await Deno.run({ cmd: ["ps"] });
} catch {
Deno.exit(0);
}