Skip to content

Commit

Permalink
close #158 and update some functions that have been removed from devt…
Browse files Browse the repository at this point in the history
…ools
  • Loading branch information
benmarwick committed Oct 16, 2024
1 parent 68d0831 commit 5c11e68
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ LazyData: true
URL: https://github.com/benmarwick/rrtools
BugReports: https://github.com/benmarwick/rrtools/issues
Suggests: testthat, quarto, knitr
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
VignetteBuilder: knitr
Date: 2019-01-15
10 changes: 7 additions & 3 deletions R/helpers_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ suggests_dep <- function(pkg) {
deps[found, ]
}

# from https://github.com/r-lib/devtools/blob/master/R/utils.R
is_installed <- function(pkg, version = 0) {
# from https://github.com/r-lib/devtools/blob/master/R/utils.R but this
# function was removed some time ago, so I've just updated it to keep it
# working
is_installed <- function(pkg, version = "0.0.0") {
installed_version <- tryCatch(utils::packageVersion(pkg), error = function(e) NA)
!is.na(installed_version) && installed_version >= version
required_version <- as.package_version(version)
!is.na(installed_version) && installed_version >= required_version
}


# from https://github.com/r-lib/devtools/blob/master/R/pkgload.R
check_suggested <- function(pkg, version = NULL, compare = NA) {

Expand Down
8 changes: 4 additions & 4 deletions R/helpers_templates.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ use_template <- function(template, save_as = template, data = list(),

path <- file.path(pkg$path, out_path, save_as)
if (!can_overwrite(path, ask = ask)) {
stop("`", save_as, "` already exists.", call. = FALSE)
stop(glue::glue("`{save_as}` already exists."), call. = FALSE)
}

template_path <- template_path_fn(template)

template_out <- whisker::whisker.render(readLines(template_path), data)

usethis::ui_done("Creating {usethis::ui_value(save_as)} from template.")
usethis::ui_done(glue::glue("Creating {usethis::ui_value(save_as)} from template."))
writeLines(template_out, path)

if (ignore) {
usethis::ui_done("Adding {usethis::ui_value(save_as)} to `.Rbuildignore`.")
usethis::ui_done(glue::glue("Adding {usethis::ui_value(save_as)} to `.Rbuildignore`."))
use_build_ignore(save_as, pkg = pkg)
}

if (open) {
usethis::ui_todo("Modify ", usethis::ui_value(save_as))
usethis::ui_todo(glue::glue("Modify {usethis::ui_value(save_as)}"))
open_in_rstudio(path)
}

Expand Down

0 comments on commit 5c11e68

Please sign in to comment.