mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -05:00
Add --allow-all flag (#1482)
This commit is contained in:
parent
6f79ad721a
commit
3afdae165d
1 changed files with 24 additions and 0 deletions
24
src/flags.rs
24
src/flags.rs
|
@ -97,6 +97,12 @@ fn set_recognized_flags(
|
|||
if matches.opt_present("allow-run") {
|
||||
flags.allow_run = true;
|
||||
}
|
||||
if matches.opt_present("allow-all") {
|
||||
flags.allow_env = true;
|
||||
flags.allow_net = true;
|
||||
flags.allow_run = true;
|
||||
flags.allow_write = true;
|
||||
}
|
||||
if matches.opt_present("types") {
|
||||
flags.types = true;
|
||||
}
|
||||
|
@ -127,6 +133,7 @@ pub fn set_flags(
|
|||
opts.optflag("", "allow-net", "Allow network access.");
|
||||
opts.optflag("", "allow-env", "Allow environment access.");
|
||||
opts.optflag("", "allow-run", "Allow running subprocesses.");
|
||||
opts.optflag("A", "allow-all", "Allow all permissions");
|
||||
opts.optflag("", "recompile", "Force recompilation of TypeScript code.");
|
||||
opts.optflag("h", "help", "Print this message.");
|
||||
opts.optflag("D", "log-debug", "Log debug output.");
|
||||
|
@ -228,6 +235,23 @@ fn test_set_flags_6() {
|
|||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_set_flags_7() {
|
||||
let (flags, rest, _) =
|
||||
set_flags(svec!["deno", "gist.ts", "--allow-all"]).unwrap();
|
||||
assert_eq!(rest, svec!["deno", "gist.ts"]);
|
||||
assert_eq!(
|
||||
flags,
|
||||
DenoFlags {
|
||||
allow_net: true,
|
||||
allow_env: true,
|
||||
allow_run: true,
|
||||
allow_write: true,
|
||||
..DenoFlags::default()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// Returns args passed to V8, followed by args passed to JS
|
||||
fn v8_set_flags_preprocess(args: Vec<String>) -> (Vec<String>, Vec<String>) {
|
||||
let (rest, mut v8_args) =
|
||||
|
|
Loading…
Reference in a new issue