Skip to content

Commit

Permalink
point out the possibly outdated packages to make it easier for users …
Browse files Browse the repository at this point in the history
…to know what to do with the deprecation of xfun::isFALSE: yihui/yihui.org#1470 (comment)
  • Loading branch information
yihui committed Nov 8, 2023
1 parent 34bf020 commit 5a1dac6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: xfun
Type: Package
Title: Supporting Functions for Packages Maintained by 'Yihui Xie'
Version: 0.41.5
Version: 0.41.6
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre", "cph"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Wush", "Wu", role = "ctb"),
Expand Down
16 changes: 15 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,28 @@ in_dir = function(dir, expr) {
#' @export
#' @keywords internal
isFALSE = function(x) {
pkgs = tools::dependsOnPkgs('xfun', dependencies = 'all', recursive = FALSE)
pkgs = intersect(pkgs, sys.packages())
vers = sapply(pkgs, function(p) as.character(packageVersion(p)))
if ('isFALSE' %in% ls(baseenv())) stop(
'The function xfun::isFALSE() has been deprecated. Please ',
'consider using base::isFALSE(x) or identical(x, FALSE) instead. ',
if (length(vers)) {
c('update the possibly outdated package(s): ', paste(pkgs, vers, sep = ' ', collapse = ', '), '. ')
} else {
'consider using base::isFALSE(x) or identical(x, FALSE) instead. '
},
'You may see https://yihui.org/en/2023/02/xfun-isfalse/ for more info.'
)
identical(x, FALSE)
}

# try to get the names of packages for all functions on the call stack
sys.packages = function() {
unique(unlist(lapply(seq_along(sys.calls()), function(i) {
environment(sys.function(i))$.packageName
})))
}

#' Parse R code and do not keep the source
#'
#' An abbreviation of `parse(keep.source = FALSE)`.
Expand Down

0 comments on commit 5a1dac6

Please sign in to comment.