Skip to content

Commit

Permalink
import functions from xfun 0.20
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Jan 6, 2021
1 parent 421c5c9 commit cd5c87e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 30 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: blogdown
Type: Package
Title: Create Blogs and Websites with R Markdown
Version: 0.21.78
Version: 0.21.79
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
person("Christophe", "Dervieux", role = "aut", email = "cderv@rstudio.com", comment = c(ORCID = "0000-0003-4474-2498")),
Expand Down Expand Up @@ -47,7 +47,7 @@ Imports:
yaml (>= 2.1.19),
httpuv (>= 1.4.0),
later,
xfun (>= 0.19),
xfun (>= 0.20),
servr (>= 0.21)
Suggests:
testit,
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Expand Up @@ -50,11 +50,15 @@ export(yaml2toml)
import(stats)
import(utils)
importFrom(xfun,attr)
importFrom(xfun,del_empty_dir)
importFrom(xfun,dir_create)
importFrom(xfun,dir_exists)
importFrom(xfun,file_exists)
importFrom(xfun,file_ext)
importFrom(xfun,in_dir)
importFrom(xfun,is_macos)
importFrom(xfun,is_windows)
importFrom(xfun,msg_cat)
importFrom(xfun,proc_kill)
importFrom(xfun,read_utf8)
importFrom(xfun,write_utf8)
5 changes: 1 addition & 4 deletions R/package.R
Expand Up @@ -12,16 +12,13 @@
#' @import utils
#' @import stats
#' @importFrom xfun attr in_dir read_utf8 write_utf8 is_windows is_macos
#' file_exists dir_exists file_ext
#' file_exists dir_exists file_ext msg_cat dir_create del_empty_dir proc_kill
#' @examples if (interactive()) blogdown::new_site()
NULL

with_ext = function(...) xfun::with_ext(...)
existing_files = bookdown:::existing_files
fetch_yaml = function(f) bookdown:::fetch_yaml(read_utf8(f))
# TODO: use functions from xfun
dir_create = function(x) xfun:::dir_create(x)
del_empty_dir = bookdown:::clean_empty_dir

`%n%` = knitr:::`%n%`

Expand Down
16 changes: 0 additions & 16 deletions R/serve.R
Expand Up @@ -248,22 +248,6 @@ stop_server = function() {
opts$set(pids = NULL, served_dirs = NULL)
}

# TODO: remove the following two functions and import xfun::proc_kill() after
# xfun 0.20 is released because 0.19 contains a bug
proc_kill = function(pid, recursive = TRUE, ...) {
if (is_windows()) {
xfun::proc_kill(pid, recursive, ...)
} else {
system2('kill', c(pid, if (recursive) child_pids(pid)), ...)
}
}
child_pids = function(id) {
x = system2('sh', shQuote(c(
system.file('scripts', 'child_pids.sh', package = 'xfun'), id
)), stdout = TRUE)
grep('^[0-9]+$', x, value = TRUE)
}

get_config2 = function(key, default) {
res = yaml_load_file('_config.yml')
res[[key]] %n% default
Expand Down
8 changes: 0 additions & 8 deletions R/utils.R
Expand Up @@ -239,14 +239,6 @@ message2 = function(..., files = NULL) {
for (f in files) open_file(f)
}

# TODO: use xfun::msg_cat() in xfun 0.20
msg_cat = function(...) {
x = paste(c(...), collapse = '')
withRestarts({
signalCondition(simpleMessage(x))
cat(x)
}, muffleMessage = function() invisible(NULL))
}
msg1 = function(...) msg_cat('* ', ..., '\n')
msg2 = function(...) msg_cat('\n==> ', ..., '\n\n')

Expand Down

0 comments on commit cd5c87e

Please sign in to comment.