Skip to content

Commit

Permalink
Merge pull request #85 from odradev/bugfix/odra-modules-will-smith
Browse files Browse the repository at this point in the history
Fix for modules dependency being badly replaced in project template
  • Loading branch information
kubaplas authored May 16, 2024
2 parents 2453c04 + e4f4bbb commit a668180
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/actions/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl InitAction {
&cargo_toml_path,
"#odra_dependency",
"odra",
"odra",
);

Self::replace_package_placeholder(
Expand All @@ -128,6 +129,7 @@ impl InitAction {
&cargo_toml_path,
"#odra_test_dependency",
"odra-test",
"odra-test",
);

Self::replace_package_placeholder(
Expand All @@ -136,13 +138,15 @@ impl InitAction {
&cargo_toml_path,
"#odra_build_dependency",
"odra-build",
"odra-build",
);

Self::replace_package_placeholder(
init,
&odra_location,
&cargo_toml_path,
"#odra_modules_dependency",
"odra-modules",
"modules",
);

Expand All @@ -156,6 +160,7 @@ impl InitAction {
cargo_toml_path: &Path,
placeholder: &str,
crate_name: &str,
crate_path: &str,
) {
replace_in_file(
cargo_toml_path.to_path_buf(),
Expand All @@ -165,7 +170,7 @@ impl InitAction {
crate_name,
toml::to_string(&Self::odra_project_dependency(
odra_location.clone(),
crate_name,
crate_path,
init
))
.unwrap()
Expand All @@ -183,7 +188,7 @@ impl InitAction {

fn odra_project_dependency(
odra_location: OdraLocation,
crate_name: &str,
crate_path: &str,
init: bool,
) -> Dependency {
let (version, path, git, branch) = match odra_location {
Expand All @@ -193,7 +198,7 @@ impl InitAction {
false => PathBuf::from("..").join(path),
};
let path = path
.join(crate_name)
.join(crate_path)
.into_os_string()
.to_str()
.unwrap()
Expand Down
1 change: 1 addition & 0 deletions src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ pub const MODULE_TEMPLATE: &str = "flipper";
/// Module register snippet.
pub const MODULE_REGISTER: &str = "module_register";

/// Path of templates.json file in Odra repository.
pub const TEMPLATES_JSON_PATH: &str = "templates/templates.json";

0 comments on commit a668180

Please sign in to comment.