From ea86c0818ab6bf15d648726f0b18204a1dc83709 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 10 Jan 2022 09:22:03 -0500 Subject: fix: install shim with `--allow-all` should not output each permission individually (#13325) --- cli/tools/installer.rs | 37 +++++++++++++++++++++++++++++++++++++ cli/tools/standalone.rs | 1 + 2 files changed, 38 insertions(+) (limited to 'cli/tools') diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index ac164a2f3..b65de2615 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -729,6 +729,43 @@ mod tests { } } + #[test] + fn install_allow_all() { + let temp_dir = TempDir::new().expect("tempdir fail"); + let bin_dir = temp_dir.path().join("bin"); + std::fs::create_dir(&bin_dir).unwrap(); + + install( + Flags { + allow_all: true, + ..Flags::default() + }, + InstallFlags { + module_url: "http://localhost:4545/echo_server.ts".to_string(), + args: vec![], + name: Some("echo_test".to_string()), + root: Some(temp_dir.path().to_path_buf()), + force: false, + }, + ) + .unwrap(); + + let mut file_path = bin_dir.join("echo_test"); + if cfg!(windows) { + file_path = file_path.with_extension("cmd"); + } + + let content = fs::read_to_string(file_path).unwrap(); + if cfg!(windows) { + assert!(content.contains( + r#""run" "--allow-all" "http://localhost:4545/echo_server.ts""# + )); + } else { + assert!(content + .contains(r#"run --allow-all 'http://localhost:4545/echo_server.ts'"#)); + } + } + #[test] fn install_local_module() { let temp_dir = TempDir::new().expect("tempdir fail"); diff --git a/cli/tools/standalone.rs b/cli/tools/standalone.rs index f6b89caa2..a29b405ba 100644 --- a/cli/tools/standalone.rs +++ b/cli/tools/standalone.rs @@ -204,6 +204,7 @@ pub fn compile_to_runtime_flags( subcommand: DenoSubcommand::Run(RunFlags { script: "placeholder".to_string(), }), + allow_all: flags.allow_all, allow_env: flags.allow_env, allow_hrtime: flags.allow_hrtime, allow_net: flags.allow_net, -- cgit v1.2.3