32 lines
715 B
TypeScript
32 lines
715 B
TypeScript
import { readFileSync } from "node:fs";
|
|
|
|
function isWSL(): boolean {
|
|
if (process.platform !== "linux") return false;
|
|
try {
|
|
const release = readFileSync("/proc/version", "utf8").toLowerCase();
|
|
return release.includes("microsoft") || release.includes("wsl");
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function isRemoteEnvironment(): boolean {
|
|
if (process.env.SSH_CLIENT || process.env.SSH_TTY || process.env.SSH_CONNECTION) {
|
|
return true;
|
|
}
|
|
|
|
if (process.env.REMOTE_CONTAINERS || process.env.CODESPACES) {
|
|
return true;
|
|
}
|
|
|
|
if (
|
|
process.platform === "linux" &&
|
|
!process.env.DISPLAY &&
|
|
!process.env.WAYLAND_DISPLAY &&
|
|
!isWSL()
|
|
) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|