-
Notifications
You must be signed in to change notification settings - Fork 484
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
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.
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.
Sorry for taking so long to get this in! I made [no-cd]
and [working-directory]
conflict, so you can't have them both on a recipe. I also added an expect_file
function to the test runner, which allowed the tests to be simplified, since you can touch
a file and check that a file in the expected directory was created.
Thanks @casey! Looking forward to using this in my projects 😍 |
Closes #2082