mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
fix(cli): fix deno install --prompt
(#13349)
This commit is contained in:
parent
919ded1a0b
commit
9e37fd1db6
1 changed files with 41 additions and 0 deletions
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue