diff options
author | Tomofumi Chiba <tomofumi.chiba@gmail.com> | 2022-01-14 23:59:32 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-14 09:59:32 -0500 |
commit | 9e37fd1db6659aafc42d80fa432ecf9bec24af6c (patch) | |
tree | 069c7069040753d46a92ff25db8a791650b43eb7 /cli/tools/installer.rs | |
parent | 919ded1a0b3439ef0d2d3134603bf5840ea0a170 (diff) |
fix(cli): fix `deno install --prompt` (#13349)
Diffstat (limited to 'cli/tools/installer.rs')
-rw-r--r-- | cli/tools/installer.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index b65de2615..e762e064c 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -290,6 +290,10 @@ pub fn install( executable_args.push("--cached-only".to_string()); } + if flags.prompt { + executable_args.push("--prompt".to_string()); + } + if !flags.v8_flags.is_empty() { executable_args.push(format!("--v8-flags={}", flags.v8_flags.join(","))); } @@ -550,6 +554,43 @@ mod tests { } #[test] + fn install_prompt() { + 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 { + prompt: 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" "--prompt" "http://localhost:4545/echo_server.ts""# + )); + } else { + assert!(content + .contains(r#"run --prompt 'http://localhost:4545/echo_server.ts'"#)); + } + } + + #[test] fn install_inferred_name() { let temp_dir = TempDir::new().expect("tempdir fail"); let bin_dir = temp_dir.path().join("bin"); |