1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

fix(cli): fix deno install --prompt (#13349)

This commit is contained in:
Tomofumi Chiba 2022-01-14 23:59:32 +09:00 committed by GitHub
parent 919ded1a0b
commit 9e37fd1db6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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");