or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-is-ci

Detect if the current environment is a CI server

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/is-ci@4.1.x

To install, run

npx @tessl/cli install tessl/npm-is-ci@4.1.0

index.mddocs/

is-ci

Returns 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.

Package Information

  • Package Name: is-ci
  • Package Type: npm
  • Language: JavaScript (with TypeScript definitions)
  • Installation: npm install is-ci

Core Imports

const isCI = require('is-ci');

For TypeScript:

import isCI = require('is-ci');

Basic Usage

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"

Capabilities

CI Detection (Programmatic)

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';
}

CI Detection (Command Line)

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 environment

Installation Options:

  • Global: npm install -g is-ci
  • Local dependency: npm install is-ci (accessible via ./node_modules/.bin/is-ci)
  • Package.json scripts: Use is-ci directly in scripts section

Usage 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

Types

/**
 * TypeScript definition for the is-ci module
 * Re-exports the isCI boolean from ci-info package
 */
declare const isCI: boolean;
export = isCI;

Supported CI Platforms

This package supports all CI platforms supported by the underlying ci-info dependency, including but not limited to:

  • GitHub Actions
  • Travis CI
  • CircleCI
  • Jenkins
  • GitLab CI
  • Azure DevOps
  • AWS CodeBuild
  • Bitbucket Pipelines
  • And many more

For the complete list, refer to the ci-info documentation.

Error Handling

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.