Skip to content

Commit

Permalink
minor improvements in listing installed java in project dir
Browse files Browse the repository at this point in the history
  • Loading branch information
e-kotov committed Aug 20, 2024
1 parent 256d15d commit 569852b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions R/java_manage_project.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,25 @@ java_list_in_project <- function(
java_symlink_dir <- file.path(project_path, "rjavaenv")

if (!dir.exists(java_symlink_dir)) {
cli::cli_alert_danger("Project Java symlink directory does not exist")
return(character(0))
cli::cli_alert_danger("No Java has been installed in the project.")
return(invisible(NULL))
}

if (verbose) cli::cli_inform("Contents of the Java symlinks in the project folder:")


# List directories up to the specified depth
java_paths <- list.dirs(java_symlink_dir, recursive = TRUE, full.names = TRUE)

java_paths <- java_paths[vapply(java_paths, function(x) {
length(strsplit(x, .Platform$file.sep)[[1]]) == length(strsplit(java_symlink_dir, .Platform$file.sep)[[1]]) + 3
}, logical(1))]

if (length(java_paths) == 0) {
return(character(0))
cli::cli_alert_danger("No Java has been installed in the project.")
return(invisible(NULL))
}


if (verbose) cli::cli_inform("Contents of the Java symlinks in the project folder:")

if (output == "vector") {
return(unname(java_paths))
} else if (output == "data.frame") {
Expand Down

0 comments on commit 569852b

Please sign in to comment.