Skip to content

Commit

Permalink
Added conditional compilation for Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
DobromirM committed Oct 12, 2023
1 parent 69b8bbb commit b475188
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
}
Expand Down Expand Up @@ -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<String, Box<dyn Error>> {
let output_dir = Path::new(&args.name).join(input_dir.strip_prefix(PROJECT_TEMPLATE_FOLDER)?);
replace_text(&output_dir.display().to_string(), args)
Expand Down

0 comments on commit b475188

Please sign in to comment.