Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 4 additions & 1 deletion 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 @@ -443,6 +444,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 @@ -2592,7 +2595,7 @@ fn permission_args_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
flags.allow_ffi = Some(vec![]);
flags.allow_hrtime = true;
}
if matches.is_present("no-prompt") {
if env::var("DENO_NO_PROMPT").is_ok() || matches.is_present("no-prompt") {
flags.no_prompt = true;
}
}
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 @@ -2613,3 +2613,23 @@ itest!(unstable_ffi_15 {
output: "unstable_ffi_15.js.out",
exit_code: 70,
});

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);
}