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:
parent
a913b7a1ba
commit
36ad4e3b77
2 changed files with 62 additions and 0 deletions
24
cli/flags.rs
24
cli/flags.rs
|
@ -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![
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Add table
Reference in a new issue