Skip to content

Commit

Permalink
Use {pak} for downloading suggested dependencies? (#418)
Browse files Browse the repository at this point in the history
* Use `{pak}` for downloading suggested dependencies?
Fixes #413

* version
  • Loading branch information
strengejacke committed Jun 18, 2024
1 parent 23116ec commit b4d3761
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Suggests:
jsonlite,
knitr,
mockery,
pak,
patchwork,
rmarkdown,
testthat (>= 3.2.1),
Expand Down
28 changes: 18 additions & 10 deletions R/easystats_update.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ easystats_update <- function(which = c("all", "core", "deps")) {
# detach packages before installing
lapply(behind$package, unloadNamespace)

utils::install.packages(
behind$package,
quiet = TRUE,
dependencies = FALSE
)
if (insight::check_if_installed("pak", quietly = TRUE)) {
pak::pkg_install(behind$package)
} else {
utils::install.packages(
behind$package,
quiet = TRUE,
dependencies = FALSE
)
}
}

if (which %in% c("all", "deps")) {
Expand All @@ -69,11 +73,15 @@ easystats_update <- function(which = c("all", "core", "deps")) {
# detach packages before installing
lapply(behind$package, unloadNamespace)

utils::install.packages(
behind$package,
quiet = TRUE,
dependencies = FALSE
)
if (insight::check_if_installed("pak", quietly = TRUE)) {
pak::pkg_install(behind$package)
} else {
utils::install.packages(
behind$package,
quiet = TRUE,
dependencies = FALSE
)
}
}

invisible()
Expand Down
2 changes: 2 additions & 0 deletions R/install_suggested.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ install_suggested <- function(package = "easystats") {

if (all(installed_packages)) {
message("All of the suggested packages are already installed :)")
} else if (insight::check_if_installed("pak", quietly = TRUE)) {
pak::pkg_install(pkg_download[!installed_packages], dependencies = FALSE)
} else {
utils::install.packages(pkg_download[!installed_packages])
}
Expand Down
3 changes: 1 addition & 2 deletions man/install_suggested.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b4d3761

Please sign in to comment.