Skip to content

Commit

Permalink
ensure heredoc included with bootstrap script (#1874)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Apr 11, 2024
1 parent f33b0c7 commit ff601c5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 15 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

# renv (development version)

* Fixed an issue where `renv`'s activate script failed to report version
conflict errors when starting up. (#1874)


# renv 1.0.6

* Fixed an issue where downloads could fail with curl >= 8.7.1. (#1869)
Expand Down
15 changes: 15 additions & 0 deletions R/bootstrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ header <- function(label,

}

heredoc <- function(text, leave = 0) {

# remove leading, trailing whitespace
trimmed <- gsub("^\\s*\\n|\\n\\s*$", "", text)

# split into lines
lines <- strsplit(trimmed, "\n", fixed = TRUE)[[1L]]

# compute common indent
indent <- regexpr("[^[:space:]]", lines)
common <- min(setdiff(indent, -1L)) - leave
paste(substring(lines, common), collapse = "\n")

}

startswith <- function(string, prefix) {
substring(string, 1, nchar(prefix)) == prefix
}
Expand Down
15 changes: 0 additions & 15 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -381,21 +381,6 @@ nth <- function(x, i) {
x[[i]]
}

heredoc <- function(text, leave = 0) {

# remove leading, trailing whitespace
trimmed <- gsub("^\\s*\\n|\\n\\s*$", "", text)

# split into lines
lines <- strsplit(trimmed, "\n", fixed = TRUE)[[1L]]

# compute common indent
indent <- regexpr("[^[:space:]]", lines)
common <- min(setdiff(indent, -1L)) - leave
paste(substring(lines, common), collapse = "\n")

}

find <- function(x, f, ...) {
for (i in seq_along(x))
if (!is.null(value <- f(x[[i]], ...)))
Expand Down
15 changes: 15 additions & 0 deletions inst/resources/activate.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ local({

}

heredoc <- function(text, leave = 0) {

# remove leading, trailing whitespace
trimmed <- gsub("^\\s*\\n|\\n\\s*$", "", text)

# split into lines
lines <- strsplit(trimmed, "\n", fixed = TRUE)[[1L]]

# compute common indent
indent <- regexpr("[^[:space:]]", lines)
common <- min(setdiff(indent, -1L)) - leave
paste(substring(lines, common), collapse = "\n")

}

startswith <- function(string, prefix) {
substring(string, 1, nchar(prefix)) == prefix
}
Expand Down

0 comments on commit ff601c5

Please sign in to comment.