Skip to content

Commit

Permalink
Use NA to signal webR pre-modified remotes list
Browse files Browse the repository at this point in the history
For `rwasm::build()`, default to no overrides.
  • Loading branch information
georgestagg committed Nov 30, 2023
1 parent 8504db7 commit aeba3ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions R/build.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#'
#' @param packages A character vector of one or more package references.
#' @param remotes A character vector of package references to prefer as a remote
#' source. If `NULL`, use a built-in list of references to packages
#' pre-modified for use with webR.
#' source. If `NA`, use a built-in list of references to packages pre-modified
#' for use with webR. Defaults to `NULL`, meaning no preference over the usual
#' remote sources.
#' @param out_dir The output directory. Defaults to `"."`.
#' @param dependencies Dependency specification for packages to additionally
#' build. Defaults to `FALSE`, meaning no additional packages. See
Expand Down
14 changes: 9 additions & 5 deletions R/repo.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ add_list <- function(list_file, ...) {
#'
#' @param packages A character vector of one or more package references.
#' @param remotes A character vector of package references to prefer as a remote
#' source. If `NULL`, use a built-in list of references to packages
#' pre-modified for use with webR.
#' source. Defaults to `NA`, meaning prefer a built-in list of references to
#' packages pre-modified for use with webR.
#' @param repo_dir The package repository directory. Defaults to `"./repo"`.
#' @param dependencies Dependency specification for packages to additionally
#' add to the repository. Defaults to `NA`, meaning add only the required
Expand All @@ -84,7 +84,7 @@ add_list <- function(list_file, ...) {
#' @importFrom pkgdepends new_pkg_download_proposal
#' @export
add_pkg <- function(packages,
remotes = NULL,
remotes = NA,
repo_dir = "./repo",
dependencies = NA) {
# Set up pkgdepends configuration
Expand Down Expand Up @@ -143,8 +143,12 @@ write_packages <- function(repo_dir = "./repo") {
# override some packages so that they are downloaded from r-wasm/[...] by
# default, rather than CRAN.
#' @importFrom rlang .data
prefer_remotes <- function(package_info, remotes = NULL) {
prefer_remotes <- function(package_info, remotes = NA) {
if (is.null(remotes)) {
return(package_info)
}

if (is.na(remotes)) {
remotes <- system.file("webr-remotes", package = "rwasm") |>
readLines() |>
unique()
Expand Down Expand Up @@ -176,7 +180,7 @@ prefer_remotes <- function(package_info, remotes = NULL) {

# Build packages and update a CRAN-like repo on disk
update_repo <- function(package_info,
remotes = NULL,
remotes = NA,
repo_dir = "./repo") {
r_version <- R_system_version(getOption("rwasm.webr_version"))

Expand Down

0 comments on commit aeba3ba

Please sign in to comment.