summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/flags.rs24
-rw-r--r--cli/installer.rs38
2 files changed, 62 insertions, 0 deletions
diff --git a/cli/flags.rs b/cli/flags.rs
index 239382e03..decf3cb17 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -2054,6 +2054,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![
"deno",
diff --git a/cli/installer.rs b/cli/installer.rs
index e402b8d03..e16c9f892 100644
--- a/cli/installer.rs
+++ b/cli/installer.rs
@@ -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);
@@ -355,6 +360,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");
let bin_dir = temp_dir.path().join("bin");