0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

fix(install): Propagate --unstable flag (#5061)

This commit is contained in:
Divya 2020-05-04 06:35:00 -05:00 committed by GitHub
parent a913b7a1ba
commit 36ad4e3b77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 0 deletions

View file

@ -2053,6 +2053,30 @@ mod tests {
);
}
#[test]
fn install_unstable() {
let r = flags_from_vec_safe(svec![
"deno",
"install",
"--unstable",
"https://deno.land/std/examples/colors.ts"
]);
assert_eq!(
r.unwrap(),
Flags {
unstable: true,
subcommand: DenoSubcommand::Install {
name: None,
module_url: "https://deno.land/std/examples/colors.ts".to_string(),
args: svec![],
root: None,
force: false,
},
..Flags::default()
}
);
}
#[test]
fn install_with_args() {
let r = flags_from_vec_safe(svec![

View file

@ -208,6 +208,11 @@ pub fn install(
executable_args.push(log_level.to_string());
}
}
if flags.unstable {
executable_args.push("--unstable".to_string());
}
executable_args.push(module_url.to_string());
executable_args.extend_from_slice(&args);
@ -354,6 +359,39 @@ mod tests {
}
}
#[test]
fn install_unstable() {
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 {
unstable: true,
..Flags::default()
},
"http://localhost:4545/cli/tests/echo_server.ts",
vec![],
Some("echo_test".to_string()),
Some(temp_dir.path().to_path_buf()),
false,
)
.expect("Install failed");
let mut file_path = bin_dir.join("echo_test");
if cfg!(windows) {
file_path = file_path.with_extension("cmd");
}
assert!(file_path.exists());
let content = fs::read_to_string(file_path).unwrap();
println!("this is the file path {:?}", content);
assert!(content.contains(
r#""run" "--unstable" "http://localhost:4545/cli/tests/echo_server.ts"#
));
}
#[test]
fn install_inferred_name() {
let temp_dir = TempDir::new().expect("tempdir fail");