Component evidence
Utility function to detect if the process is running in a headless environment, useful for CLI tools.
// Source: https://github.com/instantdb/instant | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
export function isHeadlessEnvironment(opts?: { headless?: boolean }) {
const noBrowserMode = Boolean(
process.env.INSTANT_CLI_NO_BROWSER || process.env.CI || opts?.headless,
);
// Check for common headless environment indicators
return (
noBrowserMode ||
process.env.TERM === 'dumb' ||
process.env.SSH_CONNECTION !== undefined ||
process.env.SSH_CLIENT !== undefined ||
(!process.env.DISPLAY && process.platform === 'linux') ||
process.env.WSL_DISTRO_NAME !== undefined
);
}