diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index b65de26150..e762e064cd 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(","))); } @@ -549,6 +553,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");