-
Notifications
You must be signed in to change notification settings - Fork 476
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
feat: Add working-directory attribute #2438
base: master
Are you sure you want to change the base?
feat: Add working-directory attribute #2438
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed, see comments!
src/recipe.rs
Outdated
} | ||
|
||
let working_dir = self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is better implemented as a for loop:
let working_directory = context.working_directory();
for attribute in self.attributes {
if let Attribute::WorkingDirectory(dir) = attribute {
return Some(working_directory.join(dir.cooked);
}
}
Some(working_directory)
Also note the use of cooked
, which is the contents of the string literal after processing escape sequences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is better implemented as a for loop
Yup, the suggested for loop reads better and is more concise. Just curious, is there any other reason you suggested this refactor?
Also note the use of cooked, which is the contents of the string literal after processing escape sequences.
Good to know - thanks for the info!
tests/working_directory.rs
Outdated
echo "$(basename "$PWD")" | ||
|
||
[working-directory('bar')] | ||
[working-directory('baz')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate working directory attributes should be an error.
Closes #2082