Skip to content

Commit

Permalink
refactor: normalize paths
Browse files Browse the repository at this point in the history
  • Loading branch information
luciorq committed Oct 18, 2024
1 parent 171b094 commit 496c7eb
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions R/get_install_dir.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#' @export
get_install_dir <- function() {
dir_path <- get_condathis_path()
dir_path <- base::normalizePath(dir_path)
if (isFALSE(fs::dir_exists(dir_path))) {
fs::dir_create(dir_path)
}
Expand Down
3 changes: 2 additions & 1 deletion R/list_envs.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ list_envs <- function(verbose = "silent") {
)
if (isTRUE(px_res$status == 0)) {
envs_list <- jsonlite::fromJSON(px_res$stdout)
envs_str <- fs::path_real(envs_list$envs)
envs_str <- base::normalizePath(envs_list$envs)
envs_str <- fs::path_real(envs_str)
envs_str <- envs_str[stringr::str_detect(c(envs_str), env_root_dir)]
envs_to_return <- base::basename(envs_str)
envs_to_return <- envs_to_return[!envs_to_return %in% "condathis"]
Expand Down
3 changes: 2 additions & 1 deletion R/micromamba_user_installed.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' Checks if user already have `micromamba` binaries available on `PATH`.
#'
#'
#' @keywords internal
micromamba_user_installed <- function() {
umamba_bin_path <- Sys.which("micromamba")
if (isTRUE(umamba_bin_path == "")) {
Expand All @@ -11,5 +11,6 @@ micromamba_user_installed <- function() {
if (isTRUE(umamba_bin_path == "")) {
return(invisible(umamba_bin_path))
}
umamba_bin_path <- normalizePath(umamba_bin_path)
return(fs::path(umamba_bin_path))
}
1 change: 1 addition & 0 deletions R/native_cmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ native_cmd <- function(conda_cmd,
}

umamba_bin_path <- micromamba_bin_path()
umamba_bin_path <- base::normalizePath(umamba_bin_path)
env_root_dir <- get_install_dir()

if (isFALSE(fs::file_exists(umamba_bin_path))) {
Expand Down
1 change: 1 addition & 0 deletions man/micromamba_user_installed.Rd

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

0 comments on commit 496c7eb

Please sign in to comment.