-
Notifications
You must be signed in to change notification settings - Fork 434
Expand file tree
/
Copy pathplatform.ts
More file actions
103 lines (79 loc) · 2.33 KB
/
platform.ts
File metadata and controls
103 lines (79 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* platform.ts
*
* Copyright (C) 2020-2022 Posit Software, PBC
*/
import { isWindows } from "../deno_ral/platform.ts";
export function isMingw() {
return isWindows && !!Deno.env.get("MSYSTEM");
}
export function isWSL() {
return !!Deno.env.get("WSL_DISTRO_NAME");
}
export function isRStudio() {
return !!Deno.env.get("RSTUDIO");
}
export function isPositron() {
return !!Deno.env.get("POSITRON");
}
export function isVSCodeOutputChannel() {
return !!Deno.env.get("VSCODE_PID");
}
export function isVSCodeTerminal() {
return Deno.env.get("TERM_PROGRAM") === "vscode";
}
export function isVSCodeServer() {
return !!vsCodeServerProxyUri();
}
export function isPositWorkbench() {
// RS_SERVER_URL e.g. https://daily-rsw.soleng.rstudioservices.com/
// RS_SESSION_URL e.g. /s/eae053c9ab5a71168ee19/
return !!Deno.env.get("RS_SERVER_URL") && !!Deno.env.get("RS_SESSION_URL");
}
export function isRStudioTerminal() {
return !!Deno.env.get("RSTUDIO_TERM");
}
export function isPositronTerminal() {
// it seems there is no POSITRON_TERM variable set
return isPositron();
}
export function isServerSession() {
return isRStudioServer() || isPositWorkbench() || isJupyterServer() ||
isJupyterHubServer() || isVSCodeServer();
}
export function isRStudioServer() {
return isRStudio() && Deno.env.get("RSTUDIO_PROGRAM_MODE") === "server";
}
export function isRStudioPreview() {
return isRStudio() && !isRStudioTerminal();
}
export function isJupyterServer() {
return !!Deno.env.get("JUPYTER_SERVER_URL");
}
export function isJupyterHubServer() {
return !!jupyterHubUser() && !!jupyterHubServicePrefix();
}
export function vsCodeServerProxyUri() {
return Deno.env.get("VSCODE_PROXY_URI");
}
export function jupyterHubHttpReferrer() {
return Deno.env.get("JUPYTERHUB_HTTP_REFERER");
}
export function jupyterHubUser() {
return Deno.env.get("JUPYTERHUB_USER");
}
export function jupyterHubServicePrefix() {
return Deno.env.get("JUPYTERHUB_SERVICE_PREFIX");
}
export function isInteractiveTerminal() {
return Deno.stderr.isTerminal();
}
export function isInteractiveSession() {
return isRStudio() || isInteractiveTerminal() || isVSCodeOutputChannel();
}
export function isGithubAction() {
return Deno.env.get("GITHUB_ACTIONS") === "true";
}
export function nullDevice() {
return isWindows ? "NUL" : "/dev/null";
}