Skip to content

Commit

Permalink
Add support for odra-test dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
kpob committed Jan 17, 2024
1 parent 25cbe37 commit d249b6d
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions src/actions/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,35 @@ impl InitAction {
};

replace_in_file(
cargo_toml_path,
cargo_toml_path.clone(),
"#odra_dependency",
format!(
"odra = {{ {} }}",
toml::to_string(&Self::odra_project_dependency(odra_location, init))
.unwrap()
.trim_end()
.replace('\n', ", ")
toml::to_string(&Self::odra_project_dependency(
odra_location.clone(),
"odra",
init
))
.unwrap()
.trim_end()
.replace('\n', ", ")
)
.as_str(),
);

replace_in_file(
cargo_toml_path,
"#odra_test_dependency",
format!(
"odra-test = {{ {} }}",
toml::to_string(&Self::odra_project_dependency(
odra_location,
"odra-test",
init
))
.unwrap()
.trim_end()
.replace('\n', ", ")
)
.as_str(),
);
Expand Down Expand Up @@ -163,15 +184,19 @@ impl InitAction {
response["tag_name"].as_str().unwrap().to_string()
}

fn odra_project_dependency(odra_location: OdraLocation, init: bool) -> Dependency {
fn odra_project_dependency(
odra_location: OdraLocation,
crate_name: &str,
init: bool,
) -> Dependency {
let (version, path, git, branch) = match odra_location {
OdraLocation::Local(path) => {
let path = match init {
true => path,
false => PathBuf::from("..").join(path),
};
let path = path
.join("odra")
.join(crate_name)
.into_os_string()
.to_str()
.unwrap()
Expand Down

0 comments on commit d249b6d

Please sign in to comment.