Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for modules dependency being badly replaced in project template #85

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
Loading