File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -56,29 +56,40 @@ verifyAvailable <- function(version_needed = NULL) {
56
56
# ' based on the version of RStudio currently available.
57
57
# '
58
58
# ' @returns A `"numeric_version"` object, giving the version of RStudio in use.
59
- # '
59
+ # '
60
60
# ' @export
61
61
getVersion <- function () {
62
- verifyAvailable()
63
-
62
+
63
+ # use API if available
64
+ if (hasFun(" getVersion" ))
65
+ return (callFun(" getVersion" ))
66
+
67
+ # use fallback if not
64
68
base <- .BaseNamespaceEnv
65
69
version <- base $ .Call(" rs_rstudioVersion" , PACKAGE = " (embedding)" )
66
70
package_version(version )
71
+
67
72
}
68
73
69
74
# ' Report whether RStudio Desktop or RStudio Server is in use
70
- # '
75
+ # '
71
76
# ' Use `getMode()` if you need to differentiate between server
72
77
# ' and desktop installations of RStudio.
73
- # '
78
+ # '
74
79
# ' @returns "desktop" for RStudio Desktop installations, and
75
80
# ' "server" for RStudio Server / RStudio Workbench installations.
76
- # '
81
+ # '
77
82
# ' @export
78
83
getMode <- function () {
79
- verifyAvailable()
84
+
85
+ # use API if available
86
+ if (hasFun(" getMode" ))
87
+ return (callFun(" getMode" ))
88
+
89
+ # use fallback if not
80
90
rstudio <- as.environment(" tools:rstudio" )
81
91
if (rstudio $ .rs.isDesktop()) " desktop" else " server"
92
+
82
93
}
83
94
84
95
You can’t perform that action at this time.
0 commit comments