@@ -585,7 +585,7 @@ dotenv_parse_dot_line <- function (line) {
585585# ' @export
586586unload_workflow_environment <- function (config ){
587587 env_vars_workflow <- as.list(Sys.getenv())
588- envfile <- config $ profile_config $ environment $ file
588+ envfile <- get_absolute_path( config $ profile_config $ environment $ file , base = config $ wd )
589589 if (! is.null(envfile )){
590590 tmp <- readLines(envfile )
591591 tmp <- dotenv_ignore_comments(tmp )
@@ -622,6 +622,32 @@ is_absolute_path <- function(path) {
622622 grepl(" ^(/|[A-Za-z]:|\\\\ |~)" , path )
623623}
624624
625+ # ' @name get_absolute_path
626+ # ' @aliases get_absolute_path
627+ # ' @title get_absolute_path
628+ # ' @description \code{get_absolute_path} allows to get the absolute path of a resource
629+ # ' given a base directory
630+ # '
631+ # ' @usage get_absolute_path(path, base, mustWork, expand_tilde)
632+ # '
633+ # ' @param path a path in character string
634+ # ' @param base a base direcotry
635+ # ' @param mustWork must work?
636+ # ' @param expand_tilde expand tilde?
637+ # '
638+ # ' @author Emmanuel Blondel, \email{emmanuel.blondel1@@gmail.com}
639+ # ' @export
640+ get_absolute_path <- function (path , base = getwd(), mustWork = FALSE , expand_tilde = TRUE ) {
641+ path <- as.character(path )
642+ base <- as.character(base )[1L ]
643+ if (expand_tilde ) {
644+ path <- ifelse(startsWith(path , " ~" ), path.expand(path ), path )
645+ base <- path.expand(base )
646+ }
647+ combined <- ifelse(is_absolute_path(path ), path , file.path(base , path ))
648+ normalizePath(combined , winslash = " /" , mustWork = mustWork )
649+ }
650+
625651# '@name get_union_bbox
626652# '@aliases get_union_bbox
627653# '@title get_union_bbox
0 commit comments