Skip to content

Commit

Permalink
Added conditional compilation for Unix.
Browse files Browse the repository at this point in the history
  • Loading branch information
DobromirM committed Oct 11, 2023
1 parent 39a1939 commit 69b8bbb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.1.0"
version = "0.2.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
6 changes: 4 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ use regex::Regex;
use serde::Serialize;
use std::error::Error;
use std::fs;
use std::os::unix::fs::PermissionsExt;
use std::path::Path;
use tera::Tera;

#[cfg(target_family = "unix")]
use std::os::unix::fs::PermissionsExt;

pub(crate) fn validate_name(name: &str) -> Result<String, CliError> {
let name = name.trim().to_lowercase();

Expand Down Expand Up @@ -47,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")
|| input_file.display().to_string().ends_with("gradlew.bat") && cfg!(unix)
{
set_executable_permissions(&output_file)?;
}
Expand Down
2 changes: 1 addition & 1 deletion templates/swim-template/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'application'

version = '0.2.0'
version = '0.0.1'
mainClassName = '{{name}}.MainPlane'
ext.moduleName = '{{name}}'

Expand Down

0 comments on commit 69b8bbb

Please sign in to comment.