Add type definitions for ci-info (#35772)

This commit is contained in:
Florian Keller 2019-05-30 21:15:34 +02:00 committed by Sheetal Nandi
parent a539320135
commit bd677abc92
6 changed files with 121 additions and 7 deletions

View File

@ -0,0 +1,33 @@
import * as ci from 'ci-info';
ci.isCI; // $ExpectType boolean
ci.isPR; // $ExpectType boolean | null
ci.name; // $ExpectType string | null
ci.APPVEYOR; // $ExpectType boolean
ci.AZURE_PIPELINES; // $ExpectType boolean
ci.BAMBOO; // $ExpectType boolean
ci.BITBUCKET; // $ExpectType boolean
ci.BITRISE; // $ExpectType boolean
ci.BUDDY; // $ExpectType boolean
ci.BUILDKITE; // $ExpectType boolean
ci.CIRCLE; // $ExpectType boolean
ci.CIRRUS; // $ExpectType boolean
ci.CODEBUILD; // $ExpectType boolean
ci.CODESHIP; // $ExpectType boolean
ci.DRONE; // $ExpectType boolean
ci.DSARI; // $ExpectType boolean
ci.GITLAB; // $ExpectType boolean
ci.GOCD; // $ExpectType boolean
ci.HUDSON; // $ExpectType boolean
ci.JENKINS; // $ExpectType boolean
ci.MAGNUM; // $ExpectType boolean
ci.NETLIFY; // $ExpectType boolean
ci.SAIL; // $ExpectType boolean
ci.SEMAPHORE; // $ExpectType boolean
ci.SHIPPABLE; // $ExpectType boolean
ci.SOLANO; // $ExpectType boolean
ci.STRIDER; // $ExpectType boolean
ci.TASKCLUSTER; // $ExpectType boolean
ci.TEAMCITY; // $ExpectType boolean
ci.TRAVIS; // $ExpectType boolean

58
types/ci-info/index.d.ts vendored Normal file
View File

@ -0,0 +1,58 @@
// Type definitions for ci-info 2.0
// Project: https://github.com/watson/ci-info
// Definitions by: Florian Keller <https://github.com/ffflorian>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Returns a boolean. Will be `true` if the code is running on a CI server,
* otherwise `false`.
*
* Some CI servers not listed here might still trigger the `ci.isCI`
* boolean to be set to `true` if they use certain vendor neutral environment
* variables. In those cases `ci.name` will be `null` and no vendor specific
* boolean will be set to `true`.
*/
export const isCI: boolean;
/**
* Returns a boolean if PR detection is supported for the current CI server.
* Will be `true` if a PR is being tested, otherwise `false`. If PR detection is
* not supported for the current CI server, the value will be `null`.
*/
export const isPR: boolean | null;
/**
* Returns a string containing name of the CI server the code is running on. If
* CI server is not detected, it returns `null`.
*
* Don't depend on the value of this string not to change for a specific vendor.
* If you find your self writing `ci.name === 'Travis CI'`, you most likely want
* to use `ci.TRAVIS` instead.
*/
export const name: string | null;
export const APPVEYOR: boolean;
export const AZURE_PIPELINES: boolean;
export const BAMBOO: boolean;
export const BITBUCKET: boolean;
export const BITRISE: boolean;
export const BUDDY: boolean;
export const BUILDKITE: boolean;
export const CIRCLE: boolean;
export const CIRRUS: boolean;
export const CODEBUILD: boolean;
export const CODESHIP: boolean;
export const DRONE: boolean;
export const DSARI: boolean;
export const GITLAB: boolean;
export const GOCD: boolean;
export const HUDSON: boolean;
export const JENKINS: boolean;
export const MAGNUM: boolean;
export const NETLIFY: boolean;
export const SAIL: boolean;
export const SEMAPHORE: boolean;
export const SHIPPABLE: boolean;
export const SOLANO: boolean;
export const STRIDER: boolean;
export const TASKCLUSTER: boolean;
export const TEAMCITY: boolean;
export const TRAVIS: boolean;

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"ci-info-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -1,8 +1,9 @@
// Type definitions for is-ci 1.1
// Type definitions for is-ci 2.0
// Project: https://github.com/watson/is-ci
// Definitions by: Arne Schubert <https://github.com/atd-schubert>
// Definitions by: Arne Schubert <https://github.com/atd-schubert>,
// Florian Keller <https://github.com/ffflorian>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = is_ci;
import { isCI } from 'ci-info';
declare const is_ci: boolean;
export = isCI;

View File

@ -1,5 +1,3 @@
import isCi = require('is-ci');
let booleanValue: boolean;
booleanValue = isCi;
isCi; // $ExpectType boolean