Detect if the current environment is a CI server
npx @tessl/cli install tessl/npm-is-ci@4.1.0Returns true if the current environment is a Continuous Integration server. This utility provides both programmatic and command-line interfaces for detecting CI environments across all major CI platforms.
npm install is-ciconst isCI = require('is-ci');For TypeScript:
import isCI = require('is-ci');const isCI = require('is-ci');
if (isCI) {
console.log('The code is running on a CI server');
} else {
console.log('The code is not running on a CI server');
}Command-line usage:
# Install globally or use in package.json scripts
is-ci && echo "This is a CI server"
# Using npx
npx is-ci && echo "This is a CI server"
# Using local installation
./node_modules/.bin/is-ci && echo "This is a CI server"Detects if the current environment is a Continuous Integration server by checking environment variables and other indicators.
/**
* Boolean value indicating whether the current environment is a CI server
* @type {boolean}
*/
const isCI = require('is-ci');Return Value: boolean - true if running in a CI environment, false otherwise
Dependencies: This value is derived from the ci-info package's isCI property, which checks for various CI environment indicators.
Usage Example:
const isCI = require('is-ci');
// Conditional logic based on CI environment
if (isCI) {
console.log('Running in CI - using production settings');
process.env.NODE_ENV = 'production';
} else {
console.log('Running locally - using development settings');
process.env.NODE_ENV = 'development';
}Command-line interface that exits with status code 0 if in CI environment, 1 otherwise.
# Command line usage
is-ci
# Exit codes:
# 0 - Running in CI environment
# 1 - Not running in CI environmentInstallation Options:
npm install -g is-cinpm install is-ci (accessible via ./node_modules/.bin/is-ci)is-ci directly in scripts sectionUsage Examples:
# Basic conditional execution
is-ci && echo "This is a CI server" || echo "This is not a CI server"
# In package.json scripts
{
"scripts": {
"ci-only": "is-ci && npm run build:production",
"local-only": "is-ci || npm run dev"
}
}
# In shell scripts
#!/bin/bash
if is-ci; then
echo "Running CI deployment"
npm run deploy
else
echo "Running local build"
npm run build:dev
fi/**
* TypeScript definition for the is-ci module
* Re-exports the isCI boolean from ci-info package
*/
declare const isCI: boolean;
export = isCI;This package supports all CI platforms supported by the underlying ci-info dependency, including but not limited to:
For the complete list, refer to the ci-info documentation.
This package does not throw exceptions. The programmatic interface always returns a boolean value, and the CLI interface always exits with either status code 0 or 1.