Runtime agnostic JavaScript utility library for environment detection, platform information, CI/CD provider detection, and runtime identification.
—
Boolean flags for detecting various environment states including CI, debug, test, production, development modes, and terminal capabilities.
Detects continuous integration environments through environment variables and provider detection.
/**
* Detects if running in a CI environment
* Based on CI environment variable or detected CI provider
*/
const isCI: boolean;Usage Examples:
import { isCI } from "std-env";
if (isCI) {
console.log("Running in CI environment");
// Disable interactive prompts
// Enable CI-specific logging
}Detects debug mode based on the DEBUG environment variable.
/**
* Detects if DEBUG environment variable is set to a truthy value
*/
const isDebug: boolean;Usage Examples:
import { isDebug } from "std-env";
if (isDebug) {
console.log("Debug mode enabled");
// Enable verbose logging
// Show debug information
}Detects test environments based on NODE_ENV or TEST environment variables.
/**
* Detects if running in test environment
* True when NODE_ENV is 'test' or TEST environment variable is truthy
*/
const isTest: boolean;Usage Examples:
import { isTest } from "std-env";
if (isTest) {
console.log("Running in test environment");
// Use test database
// Mock external services
}Detects production environments based on NODE_ENV.
/**
* Detects if NODE_ENV is set to 'production'
*/
const isProduction: boolean;Usage Examples:
import { isProduction } from "std-env";
if (isProduction) {
console.log("Running in production");
// Enable optimizations
// Disable debug features
}Detects development environments based on NODE_ENV.
/**
* Detects if NODE_ENV is 'dev' or 'development'
*/
const isDevelopment: boolean;Usage Examples:
import { isDevelopment } from "std-env";
if (isDevelopment) {
console.log("Running in development");
// Enable hot reloading
// Show development tools
}Detects minimal environments where rich UI features should be disabled.
/**
* Detects minimal environment conditions
* True when MINIMAL env var is set, running in CI, test, or TTY unavailable
*/
const isMinimal: boolean;Usage Examples:
import { isMinimal } from "std-env";
if (isMinimal) {
// Disable animations
// Use simplified output
// Skip interactive features
}Detects if stdout TTY is available for interactive features.
/**
* Detects if stdout TTY is available
* Checks process.stdout.isTTY when available
*/
const hasTTY: boolean;Usage Examples:
import { hasTTY } from "std-env";
if (hasTTY) {
// Enable interactive prompts
// Use colored output
// Show progress bars
}Detects if running in a browser environment with window object.
/**
* Detects if global window object is available
* Indicates browser environment
*/
const hasWindow: boolean;Usage Examples:
import { hasWindow } from "std-env";
if (hasWindow) {
console.log("Running in browser");
// Use browser APIs
// Access DOM
} else {
console.log("Running in server environment");
}Detects terminal color support for enhanced output formatting.
/**
* Detects if terminal supports colors
* Based on NO_COLOR, FORCE_COLOR, TTY status, and CI environment
*/
const isColorSupported: boolean;Usage Examples:
import { isColorSupported } from "std-env";
if (isColorSupported) {
console.log("\x1b[32mGreen text\x1b[0m");
} else {
console.log("Plain text");
}The environment detection uses the following logic:
env.CI is truthy OR detected CI providerenv.DEBUG is truthynodeENV === "test" OR env.TEST is truthynodeENV === "production"nodeENV === "dev" OR nodeENV === "development"env.MINIMAL is truthy OR isCI OR isTest OR !hasTTYprocess.stdout.isTTY is truthytypeof window !== "undefined"!env.NO_COLOR AND (env.FORCE_COLOR OR hasTTY OR isWindows OR isCI) AND env.TERM !== "dumb"Install with Tessl CLI
npx tessl i tessl/npm-std-env