From b47518844f07c2554fb26261e42d8481de1d9b1d Mon Sep 17 00:00:00 2001 From: Dobromir Marinov Date: Thu, 12 Oct 2023 11:51:45 +0100 Subject: [PATCH] Added conditional compilation for Windows. --- Cargo.toml | 2 +- src/utils.rs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dd9c3fe..529941c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "swim-create" -version = "0.2.0" +version = "0.3.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/utils.rs b/src/utils.rs index dc2d04a..b9c1edd 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -49,7 +49,7 @@ pub(crate) fn create_file(input_file: &Path, args: &Args) -> Result<(), CliError } else { create_regular_file(input_file, &output_file, args)?; if input_file.display().to_string().ends_with("gradlew") - || input_file.display().to_string().ends_with("gradlew.bat") && cfg!(unix) + || input_file.display().to_string().ends_with("gradlew.bat") { set_executable_permissions(&output_file)?; } @@ -88,11 +88,17 @@ pub(crate) fn create_jar_file(input_file: &Path, output_file: &String) -> Result Ok(()) } +#[cfg(target_family = "unix")] pub(crate) fn set_executable_permissions(output_file: &String) -> Result<(), CliError> { fs::set_permissions(output_file, fs::Permissions::from_mode(0o755)).unwrap(); Ok(()) } +#[cfg(target_family = "windows")] +pub(crate) fn set_executable_permissions(output_file: &String) -> Result<(), CliError> { + Ok(()) +} + pub(crate) fn get_output_dir(input_dir: &Path, args: &Args) -> Result> { let output_dir = Path::new(&args.name).join(input_dir.strip_prefix(PROJECT_TEMPLATE_FOLDER)?); replace_text(&output_dir.display().to_string(), args)