summaryrefslogtreecommitdiff
path: root/cli/tools/installer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tools/installer.rs')
-rw-r--r--cli/tools/installer.rs27
1 files changed, 23 insertions, 4 deletions
diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs
index 48aa52480..f6eb33112 100644
--- a/cli/tools/installer.rs
+++ b/cli/tools/installer.rs
@@ -43,8 +43,9 @@ fn validate_name(exec_name: &str) -> Result<(), AnyError> {
}
#[cfg(windows)]
-/// On Windows if user is using Powershell .cmd extension is need to run the
-/// installed module.
+/// On Windows, 2 files are generated.
+/// One compatible with cmd & powershell with a .cmd extension
+/// A second compatible with git bash / MINGW64
/// Generate batch script to satisfy that.
fn generate_executable_file(
file_path: PathBuf,
@@ -57,6 +58,20 @@ fn generate_executable_file(
);
let mut file = File::create(&file_path)?;
file.write_all(template.as_bytes())?;
+
+ // write file for bash
+ // create filepath without extensions
+ let mut copy_path = file_path.clone();
+ copy_path.set_extension("");
+ let template = format!(
+ r#"#!/bin/sh
+# generated by deno install
+deno {} "$@"
+"#,
+ args.join(" "),
+ );
+ let mut file = File::create(&copy_path)?;
+ file.write_all(template.as_bytes())?;
Ok(())
}
@@ -278,6 +293,10 @@ pub fn install(
println!("✅ Successfully installed {}", name);
println!("{}", file_path.to_string_lossy());
+ if cfg!(windows) {
+ file_path.set_extension("");
+ println!("{} (shell)", file_path.to_string_lossy());
+ }
let installation_dir_str = installation_dir.to_string_lossy();
if !is_in_path(&installation_dir) {
@@ -423,12 +442,12 @@ mod tests {
.expect("Install failed");
let mut file_path = temp_dir.path().join(".deno/bin/echo_test");
+ assert!(file_path.exists());
+
if cfg!(windows) {
file_path = file_path.with_extension("cmd");
}
- assert!(file_path.exists());
-
let content = fs::read_to_string(file_path).unwrap();
// It's annoying when shell scripts don't have NL at the end.
assert_eq!(content.chars().last().unwrap(), '\n');