Skip to content

Commit

Permalink
Add sysinfo()$webr (fix #133)
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Apr 19, 2024
1 parent aa57f5b commit b22bde1
Show file tree
Hide file tree
Showing 18 changed files with 66 additions and 20 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: startup
Version: 0.21.0-9000
Version: 0.21.0-9002
Title: Friendly R Startup Configuration
Depends: R (>= 2.14.0)
Suggests: commonmark, tools, tcltk
Expand All @@ -11,5 +11,5 @@ License: LGPL (>= 2.1)
LazyLoad: TRUE
URL: https://henrikbengtsson.github.io/startup/, https://github.com/HenrikBengtsson/startup
BugReports: https://github.com/HenrikBengtsson/startup/issues
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Version (development version)

## New Features

* Now `sysinfo()` return also flag `webr`, which indicates whether R
runs via WebR or not.


# Version 0.21.0 (2023-12-11)

## New Features
Expand Down
2 changes: 1 addition & 1 deletion R/is_ess.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Checks whether running R via Emacs Spekas Statistics (ESS) or not
#' Check if running R via Emacs Speaks Statistics (ESS)
#'
#' @return A logical
is_ess <- function() {
Expand Down
2 changes: 1 addition & 1 deletion R/is_microsoftr.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Checks if running R in Microsoft R Open
#' Check if running R via Microsoft R Open
#'
#' @return A logical
is_microsoftr <- function() {
Expand Down
2 changes: 1 addition & 1 deletion R/is_pqr.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Checks if running pqR (A Pretty Quick Version of R)
#' Check if running a Pretty Quick Version of R (pqR)
#'
#' @return A logical
#'
Expand Down
2 changes: 1 addition & 1 deletion R/is_radian.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Checks whether running R via radian (formerly known as rtichoke and rice) or not
#' Check if running R via radian (formerly known as rtichoke and rice)
#'
#' @return A logical
#'
Expand Down
2 changes: 1 addition & 1 deletion R/is_rscript.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Checks if running R via Rscript or not
## Checks if running R via Rscript
##
## _WARNING: This function does not work - it always returns FALSE \[1\]._
##
Expand Down
4 changes: 3 additions & 1 deletion R/is_rstudio.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#' 1. Kevin Ushey (RStudio), Check if R is running in RStudio,
#' Stackoverflow, 2016-09-23,
#' \url{https://stackoverflow.com/questions/12389158/check-if-r-is-running-in-rstudio#comment66636507_35849779}
#' 2. Jonathan McPherson (RStudio), Programmatically detect RStudio Terminal vs RStudio Console?, RStudio Community - RStudio IDE, 2018-01-10, \url{https://community.rstudio.com/t/programmatically-detect-rstudio-terminal-vs-rstudio-console/4107}
#' 2. Jonathan McPherson (RStudio), Programmatically detect RStudio Terminal vs RStudio Console?,
#' RStudio Community - RStudio IDE, 2018-01-10,
#' \url{https://forum.posit.co/t/programmatically-detect-rstudio-terminal-vs-rstudio-console/4107}
is_rstudio_console <- function() {
(Sys.getenv("RSTUDIO") == "1") && !nzchar(Sys.getenv("RSTUDIO_TERM"))
}
Expand Down
14 changes: 14 additions & 0 deletions R/is_webr.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#' Checks if running R via webR
#'
#' @return A logical
#'
#' @references
#' 1. WebR - R in the Browser, <https://docs.r-wasm.org/webr/latest/>
is_webr <- function() {
if (!"webr" %in% loadedNamespaces()) return(FALSE)
## Source: https://github.com/r-wasm/webr/issues/414
ns <- getNamespace("webr")
if (!exists("eval_js", mode = "function", envir = ns)) return(FALSE)
eval_js <- get("eval_js", mode = "function", envir = ns)
eval_js("'webr' in Module") == 1L
}
2 changes: 1 addition & 1 deletion R/is_wine.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Checks whether running R on Windows using Wine or not
#' Check if running R on Windows using Wine
#'
#' @return A logical
#'
Expand Down
1 change: 1 addition & 0 deletions R/sysinfo.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ sysinfo <- function() {
## Deprecated: Renamed rice -> rtichoke in February 2018
sysinfo$rice <- sysinfo$radian
sysinfo$pqr <- is_pqr()
sysinfo$webr <- is_webr()
sysinfo$wine <- is_wine()

## Session-specific variables
Expand Down
4 changes: 2 additions & 2 deletions man/is_ess.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/is_microsoftr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/is_pqr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/is_radian.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/is_rstudio_console.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions man/is_webr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/is_wine.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b22bde1

Please sign in to comment.