npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ci-info-next

v1.0.0

Published

Get details of the current CI environment. Heavily inspired by https://github.com/watson/ci-info-next

Downloads

3

Readme

ci-info-next

Get details of the current CI environment. This library is heavily inspired by https://github.com/watson/ci-info.

Installation

Note: this library needs Node.js and a console you can type in commands (PowerShell on Windows, Terminal on macOS and your favorite terminal emulator on every other OS). The minimum required version of Node.js is: 8 - codename "Carbon".

In your console, run the following command:

$ npm install ci-info-next

You can also use yarn (like we do in this project):

$ yarn add ci-info-next

Usage

The library exports the following API:

  • function detectVendor: get an array of possible CI vendors based on the defined environment variables;

    // process.env: TRAVIS='',TRAVIS_PULL_REQUEST=''
    const {detectVendor} = require('ci-info-next');
    
    console.log(detectVendor()); // Logs: ['TRAVIS']
  • function isCI: detect if the current environment is running on a Continuous Integration service;

    // On your PC
    const {isCI} = require('ci-info-next');
    
    console.log(isCI()); // Logs: false
    
    // On a CI service...
    console.log(isCI()); // Logs: true
  • function isPR: detect if the current environment is running on Pull Request build within a Continuous Integration service;

    // process.env: TRAVIS='',TRAVIS_PULL_REQUEST=''
    const {isPR} = require('ci-info-next');
    
    console.log(isPR()); // Logs: true
  • object vendors: containing the supported CI services.

Supported CI vendors

| Name | Constant | Supports PR detection | | ------------------------------------------------------------------------------- | ----------------- | --------------------- | | AppVeyor | APPVEYOR | Yes | | AWS CodeBuild | AWS_CODEBUILD | No | | Azure Pipelines | AZURE_PIPELINES | Yes | | Bamboo | BAMBOO | No | | Bitbucket Pipelines | BITBUCKET | Yes | | Bitrise | BITRISE | Yes | | Buddy | BUDDY | Yes | | Buildkite | BUILDKITE | Yes | | CircleCI | CIRCLE | Yes | | Cirrus CI | CIRRUS | Yes | | Codeship | CODESHIP | No | | Drone | DRONE | Yes | | dsari | DSARI | No | | GitHub Actions | GITHUB | Yes | | GitLab CI | GITLAB | No | | GoCD | GOCD | No | | Hudson | HUDSON | No | | Jenkins | JENKINS | Yes | | Netlify Build | NETLIFY | Yes | | Nevercode | NEVERCODE | Yes | | Sail CI | SAIL | Yes | | Semaphore | SEMAPHORE | Yes | | Shippable | SHIPPABLE | Yes | | Strider CD | STRIDER | No | | TaskCluster | TASKCLUSTER | No | | TeamCity | TEAMCITY | No | | Travis CI | TRAVIS | Yes |

API

CIVendor

name

Pretty-printable name of the CI Vendor, for example 'Travis CI'.

constant

This property is an internal "id" of the CI Vendor. This library enforces an uppercased format, for example 'TRAVIS'.

detectEnvFunction(envs)

This function checks if the specified environment variables match this vendor's required environment variables. Returns true if the current environment variables suggest that this vendor could be the one in use. Throws a TypeError if the specified envs argument is not of type 'object'.

envs

Type: object

Environment variables object that allows you to override the default process environment.

detectPRFunction(envs)

This function checks if the specified environment variables match this vendor's required environment variables for Pull Requests. Returns true if the current environment variables suggest that this vendor could be the one in use. This function returns null if the vendor does not provide a reliable way to check for a PR environment.

Throws a TypeError if the specified envs argument is not of type 'object'.

envs

Type: object

Environment variables object that allows you to override the default process environment.

detectVendor(envs?)

Returns: CIVendor[]

Tries to detect which vendors match the specified environment and returns an array of the vendors matching the specified environment.

envs

Type: object Default: process.env

Environment variables object that allows you to override the default process environment.

isCI(envs?)

This function returns whether the specified environment variables suggest a CI environment.

envs

Type: object Default: process.env

Environment variables object that allows you to override the default process environment.

isPR(envs?)

Returns whether the specified environment variables suggest a PR build in the CI system.

envs

Type: object Default: process.env

Environment variables object that allows you to override the default process environment.

vendors

This object contains all the supported CI vendors, both individually (using the CIVendor[CONSTANT] property) and collectively (all property).

Related