What is @npmcli/ci-detect?
@npmcli/ci-detect is a utility package that helps detect if your code is running in a Continuous Integration (CI) environment. It can identify various CI services and provide information about the environment.
What are @npmcli/ci-detect's main functionalities?
Detect CI Environment
This feature allows you to detect if your code is running in a CI environment and returns the name of the CI service if detected. The code sample demonstrates how to use the package to get the CI service name.
const ciDetect = require('@npmcli/ci-detect');
const ciName = ciDetect();
console.log(`Running in CI: ${ciName}`);
Check Specific CI Service
This feature allows you to check if your code is running on a specific CI service. The code sample shows how to check if the environment is Travis CI.
const ciDetect = require('@npmcli/ci-detect');
const isTravis = ciDetect() === 'travis';
console.log(`Is Travis CI: ${isTravis}`);
Other packages similar to @npmcli/ci-detect
ci-info
ci-info is a package that provides information about the current Continuous Integration environment. It can detect various CI services and provide details about the environment. Compared to @npmcli/ci-detect, ci-info offers more detailed information about the CI environment, including whether the environment is a pull request.
is-ci
is-ci is a simple package that checks if the code is running in a CI environment. It returns a boolean value indicating whether the environment is a CI service. Compared to @npmcli/ci-detect, is-ci is more straightforward and only provides a boolean result without specifying the CI service name.
@npmcli/ci-detect
Detect what kind of CI environment the program is in
USAGE
const ciDetect = require('@npmcli/ci-detect')
const inCI = ciDetect()
CIs Detected
Returns one of the following strings, or false
if none match, by looking
at the appropriate environment variables.
- gerrit
- gitlab
- circle-ci
- drone
- github-actions
- tddium
- jenkins
- gocd
- codeship (or any that set
CI_NAME
environment variable) - travis-ci
- custom (anything else that sets
CI
environment variable)