Skip to content

Commit 2981c9a

Browse files
committed
the hugo installer filename may contain withdeploy_
1 parent 7c9b18b commit 2981c9a

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# CHANGES IN blogdown VERSION 1.23
22

3+
- `hugo_installers()` can deal with Hugo installers containing the `withdeploy` feature for Hugo >= v0.137.0 now.
34

45
# CHANGES IN blogdown VERSION 1.22
56

R/install.R

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,18 @@ install_hugo_bin = function(exec, version) {
196196
#' @param version A version number. The default is to automatically detect the
197197
#' latest version. Versions before v0.17 are not supported.
198198
#' @return A data frame containing columns \code{os} (operating system),
199-
#' \code{arch} (architecture), and \code{extended} (extended version or not).
200-
#' If your R version is lower than 4.1.0, a character vector of the installer
201-
#' filenames will be returned instead.
199+
#' \code{arch} (architecture), \code{extended} (extended version or not),
200+
#' \code{withdeploy} (with the deploy feature or not). If your R version is
201+
#' lower than 4.1.0, a character vector of the installer filenames will be
202+
#' returned instead.
202203
#' @export
203204
#' @examplesIf interactive()
204205
#' blogdown::hugo_installers()
205206
#' blogdown::hugo_installers('0.89.0')
206207
#' blogdown::hugo_installers('0.17')
207208
hugo_installers = function(version = 'latest') {
208209
repo = 'gohugoio/hugo'
209-
if (version == 'latest') version = xfun::github_releases(repo, 'latest')
210+
if (version == 'latest') version = xfun::github_releases(repo, 'latest')[1]
210211
version = sub('^[vV]?', 'v', version)
211212
json = xfun::loadable('jsonlite')
212213
res = xfun::github_api(sprintf('/repos/%s/releases/tags/%s', repo, version), raw = !json)
@@ -216,19 +217,20 @@ hugo_installers = function(version = 'latest') {
216217
res = strsplit(res, '"browser_download_url":"')
217218
xfun::grep_sub('^(https://[^"]+)".*', '\\1', unlist(res))
218219
}
219-
res = grep('[.](zip|tar[.]gz)$', unlist(res), value = TRUE)
220+
res = grep('[.](zip|tar[.]gz|pkg)$', unlist(res), value = TRUE)
220221
res = basename(res)
221222
if (!'gregexec' %in% ls(baseenv())) {
222223
warning('Your R version is too low (< 4.1.0) and does not have gregexec().')
223224
return(res)
224225
gregexec = regexec # a hack to pass R CMD check without NOTE
225226
}
226-
m = gregexec('^hugo_(extended_)?([^_]+)_([^-]+)-([^.]+)[.](zip|tar[.]gz)$', res)
227-
res = lapply(regmatches(res, m), function(x) if (length(x) >= 6) x[c(1, 3, 4, 5, 2)])
227+
m = gregexec('^hugo_(extended_)?(withdeploy_)?([^_]+)_([^-]+)-([^.]+)[.]([a-z.]+)$', res)
228+
res = lapply(regmatches(res, m), function(x) if (length(x) >= 6) x[c(1, 4, 5, 6, 2, 3)])
228229
res = do.call(rbind, res)
229-
colnames(res) = c('installer', 'version', 'os', 'arch', 'extended')
230+
colnames(res) = c('installer', 'version', 'os', 'arch', 'extended', 'withdeploy')
230231
res = as.data.frame(res)
231232
res$extended = res$extended == 'extended_'
233+
res$withdeploy = res$withdeploy == 'withdeploy_'
232234
rownames(res) = res$installer
233235
res = res[, -1]
234236
res

man/hugo_installers.Rd

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)