-
Notifications
You must be signed in to change notification settings - Fork 133
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
819 - refactor use_files.R before adding replace arg #1022
819 - refactor use_files.R before adding replace arg #1022
Conversation
HI, i prefer |
fc73159
to
558de24
Compare
UpdateUpdate this PR-branch to be up-to-date with current
Notes:@ColinFay this PR is a bit of a mess unfortunately as it had to be adjusted to updates made in 7ba820b But since there is a 100% test coverage for the file Let me know if you request any other changes ! |
Aim: - reduce duplication - make long term maintanence easier - ease the later addition of 'replace'-argument as this needs then to be done only in one place How: - encapsulate internals of use_external_js_file to separate funcs - re-use separate funcs to reduce duplication in use_external_css_file Possible To-Dos: - re-use separate funcs to reduce duplication in use_external_html_template - re-use separate funcs to reduce duplication in use_external_file
- has same structure as use_external_{js,css}_file() - add check_url_valid
029ecf3
to
fc86051
Compare
- no dance for use_external_file - no url check for use_external - no new-file creation for use_external Otherwise, same internal structure as other use_external_XXX funcs
default value can be NULL and NULL can be passed as argument -> check for both cases -> use basename of the URL correctly in this case
`file_path_sans_ext(name)` gets rid of the extension this must be handled inside tests correctly
fc86051
to
54d1668
Compare
Hey, Thanks a lot for your contribution (as usual, you rock 🤘). I've worked on a full refactoring of the use_* family that you can find here : #1170 I've gone way deeper into factoring the function so that it's more consistent, and it will make it easier to add new use_* functions if we wish to. Closing this one, but hanks again 🙏 |
To fix #819 , there is the possibility to refactor the internals of
use_external_XXX
type functions inuse_files.R
prior to the addition of a new replace arg.This may or may not be useful; I think it could be, hence the draft PR with some benefits being to reduce duplication
It's easier to add the 'replace'-argument in only one place then (see last commit to this PR).
Essentially all
use_external_xxx
funcs inuse_files.R
do the same, so this PR tries to encapsulate identical behaviour into smaller maintainable pieces.Of course this proposal comes along with quite some work and probably there should be some tests added as well... happy do get on this though!