-
Notifications
You must be signed in to change notification settings - Fork 286
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
Export file-writing helpers #389
Conversation
Might be nice to add "Export edit_file" #344 to this PR, yes? |
R/write.R
Outdated
#' @param new_lines Character vector of lines to add, if not already present. | ||
#' @param quiet Logical. Whether to message about what is happening. | ||
#' | ||
#' @return Logical indicating whether a write occurred, invisibly. |
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.
@keywords internal
?
b761e65
to
145f9a0
Compare
Now includes #344 (Export edit_file) + a lot of moving functions around that I have long wanted to do. |
R/write.R
Outdated
#' readLines(tmp) | ||
#' | ||
#' ## clean up | ||
#' file.remove(tmp) |
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 wonder if there's a non-awkward way to give this a name starting with edit_
? That would make it more clearly a member of an existing family.
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.
Yeah. But perhaps write_over()
and write_utf8()
should also be exported -- why export only write_union()
? And then they make their own little family.
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.
write_utf8 definitely belongs elsewhere but seems good to export write_over
#' } | ||
edit_file <- function(path) { | ||
path <- user_path_prep(path) | ||
dir_create(path_dir(path), recursive = TRUE) |
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.
Should this call use_directory()
? The additional messaging seems like it would be nice.
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.
Hmm, I'm a bit boxed into a corner atm. use_directory()
assumes that input path
is relative to the active project. Whereas all the write_*()
helpers and edit_file()
assume the input path can be taken at face value.
I'll take this as evidence that the functions re: directory creation aren't quite right yet. Will work on that.
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.
Oh good point; can definitely happen after this PR.
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.
Will sort this out here: #393
* Make is_in_proj() resilient to there being no active project * Process input `path` with `user_path_prep()` now that it's user-accessible
10fd44d
to
32cd262
Compare
Assuming CI goes well, I think this is done. |
🎉 |
Closes #366 any chance you'd consider exporting write_union?
Closes #344 Export edit_file
helper.R
had gotten quite large and diffuse.is_in_proj()
resilient to there being no active projectedit_file()
,write_union()
,write_over()
; mark with@keywords internal
path
withuser_path_prep()
now that it's user-accessible