Skip to content

Commit

Permalink
change API using project_path
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Baumann committed Aug 11, 2023
1 parent ab3f5c9 commit 99bdc90
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
10 changes: 6 additions & 4 deletions R/find_rev.R
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ USE_RSTUDIO};


#' Invoke shell command `nix-build` from an R session
#' @param nix_file File path to the `default.nix` file. The default is
#' a `default.nix` file in the current working directory of the current R
#' @param project_path Path to the folder where the `default.nix` file resides.
# The default is `".`, which is the current working directory in the R session.
#' session.
#' @param exec_mode Either `"blocking"` (default) or `"non-blocking`. This
#' will either block the R session while the `nix-build` shell command is
Expand All @@ -400,9 +400,11 @@ USE_RSTUDIO};
#' launched, if `nix_build()` call is assigned to an R object. Otherwise, it
#' will be returned as "invisible".
#' @export
nix_build <- function(nix_file = file.path("default.nix"),
nix_build <- function(project_path = ".",
exec_mode = c("blocking", "non-blocking")) {
has_nix_build <- nix_build_installed() # TRUE if yes, FALSE if no
nix_file <- file.path(project_path, "default.nix")

stopifnot(
"Argument `nix_file` must be character of length 1." =
is.character(nix_file) && length(nix_file) == 1L,
Expand Down Expand Up @@ -441,7 +443,7 @@ nix_build <- function(nix_file = file.path("default.nix"),
}
}

# clean zombies for background/non-blocking mode
# todo (?): clean zombies for background/non-blocking mode
# rm(pid)

return(invisible(proc))
Expand Down
10 changes: 6 additions & 4 deletions dev/build_envs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ session.

```{r function-nix_build}
#' Invoke shell command `nix-build` from an R session
#' @param nix_file File path to the `default.nix` file. The default is
#' a `default.nix` file in the current working directory of the current R
#' @param project_path Path to the folder where the `default.nix` file resides.
# The default is `".`, which is the current working directory in the R session.
#' session.
#' @param exec_mode Either `"blocking"` (default) or `"non-blocking`. This
#' will either block the R session while the `nix-build` shell command is
Expand All @@ -486,9 +486,11 @@ session.
#' launched, if `nix_build()` call is assigned to an R object. Otherwise, it
#' will be returned as "invisible".
#' @export
nix_build <- function(nix_file = file.path("default.nix"),
nix_build <- function(project_path = ".",
exec_mode = c("blocking", "non-blocking")) {
has_nix_build <- nix_build_installed() # TRUE if yes, FALSE if no
nix_file <- file.path(project_path, "default.nix")
stopifnot(
"Argument `nix_file` must be character of length 1." =
is.character(nix_file) && length(nix_file) == 1L,
Expand Down Expand Up @@ -527,7 +529,7 @@ nix_build <- function(nix_file = file.path("default.nix"),
}
}
# clean zombies for background/non-blocking mode
# todo (?): clean zombies for background/non-blocking mode
# rm(pid)
return(invisible(proc))
Expand Down
8 changes: 2 additions & 6 deletions man/nix_build.Rd

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

0 comments on commit 99bdc90

Please sign in to comment.