Skip to content

Feat/recipe reference #34

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

Merged
merged 3 commits into from
Mar 23, 2025
Merged

Feat/recipe reference #34

merged 3 commits into from
Mar 23, 2025

Conversation

dubadub
Copy link
Member

@dubadub dubadub commented Mar 21, 2025

Adds support for relative paths as proposed in https://github.com/cooklang/spec/blob/main/proposals/0015-other-recipes.md.

I think we should keep extension syntax @@recipe for backward compatibility.Adds support for relative paths as proposed in https://github.com/cooklang/spec/blob/main/proposals/0015-other-recipes.md.

Comment on lines 1501 to 1507
let components: Vec<String> = path.split('/').map(String::from).collect();
let file_stem = components.last().unwrap().to_string();
// Skip the first component (./ or ../)
Some(RecipeReference {
components: components[1..components.len()-1].to_vec(),
name: file_stem.into()
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the data is cloned without need to. It can be changed to the following code to avoid it.

let mut components: Vec<String> = path.split('/').map(String::from).skip(1).collect();
let file_stem = components.pop().unwrap();
// Skip the first component (./ or ../)
Some(RecipeReference {
    components,
    name: file_stem.into()
})

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, thanks!

@Zheoni
Copy link
Contributor

Zheoni commented Mar 22, 2025

Added a comment about avoiding unnecessary cloning but it all seems good 😄

Also, when this gets merged, I can add a warning so that when the @@recipe syntax is used to change it to @./recipe

@dubadub dubadub merged commit 37fccf7 into main Mar 23, 2025
3 checks passed
@dubadub dubadub deleted the feat/recipe-reference branch March 23, 2025 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants