New upstream version 3.2.0+~cs5.1.0
Pirate Praveen
2 years ago
0 | 0 | # Changelog |
1 | ||
2 | ## v3.2.0 | |
3 | ||
4 | - support LayerCI ([#68](https://github.com/watson/ci-info/pull/68)) | |
5 | - support Appcircle ([#69](https://github.com/watson/ci-info/pull/69)) | |
6 | - support Codefresh CI ([#65](https://github.com/watson/ci-info/pull/65)) | |
7 | - Add support for nodejs v16 | |
8 | ||
9 | ## v3.1.1 | |
10 | ||
11 | Bug Fixes: | |
12 | ||
13 | - remove duplicate declaration in typings | |
14 | ||
15 | ## v3.1.0 | |
16 | ||
17 | Features: | |
18 | ||
19 | - add typings | |
20 | ||
21 | ## v3.0.0 | |
22 | ||
23 | Features: | |
24 | ||
25 | - Add support nodejs versions: 14, 15 | |
26 | - support Nevercode ([#30](https://github.com/watson/ci-info/pull/30)) | |
27 | - support Render CI ([#36](https://github.com/watson/ci-info/pull/36)) | |
28 | - support Now CI ([#37](https://github.com/watson/ci-info/pull/37)) | |
29 | - support GitLab PR ([#59](https://github.com/watson/ci-info/pull/59)) | |
30 | - support Screwdriver CD ([#60](https://github.com/watson/ci-info/pull/60)) | |
31 | - support Visual Studio App Center ([#61](https://github.com/watson/ci-info/pull/61)) | |
32 | ||
33 | Bug Fixes: | |
34 | ||
35 | - update Netlify env constant ([#47](https://github.com/watson/ci-info/pull/47)) | |
36 | ||
37 | Breaking changes: | |
38 | ||
39 | - Drop support for Node.js end-of-life versions: 6, 13 | |
40 | - replace `Zeit Now` with `Vercel` ([#55](https://github.com/watson/ci-info/pull/55)) | |
1 | 41 | |
2 | 42 | ## v2.0.0 |
3 | 43 | |
4 | 44 | Breaking changes: |
5 | 45 | |
6 | * Drop support for Node.js end-of-life versions: 0.10, 0.12, 4, 5, 7, | |
46 | - Drop support for Node.js end-of-life versions: 0.10, 0.12, 4, 5, 7, | |
7 | 47 | and 9 |
8 | * Team Foundation Server will now be detected as Azure Pipelines. The | |
48 | - Team Foundation Server will now be detected as Azure Pipelines. The | |
9 | 49 | constant `ci.TFS` no longer exists - use `ci.AZURE_PIPELINES` instead |
10 | * Remove deprecated `ci.TDDIUM` constant - use `ci.SOLANDO` instead | |
50 | - Remove deprecated `ci.TDDIUM` constant - use `ci.SOLANDO` instead | |
11 | 51 | |
12 | 52 | New features: |
13 | 53 | |
14 | * feat: support Azure Pipelines ([#23](https://github.com/watson/ci-info/pull/23)) | |
15 | * feat: support Netlify CI ([#26](https://github.com/watson/ci-info/pull/26)) | |
16 | * feat: support Bitbucket pipelines PR detection ([#27](https://github.com/watson/ci-info/pull/27)) | |
54 | - feat: support Azure Pipelines ([#23](https://github.com/watson/ci-info/pull/23)) | |
55 | - feat: support Netlify CI ([#26](https://github.com/watson/ci-info/pull/26)) | |
56 | - feat: support Bitbucket pipelines PR detection ([#27](https://github.com/watson/ci-info/pull/27)) | |
17 | 57 | |
18 | 58 | ## v1.6.0 |
19 | 59 | |
20 | * feat: add Sail CI support | |
21 | * feat: add Buddy support | |
22 | * feat: add Bitrise support | |
23 | * feat: detect Jenkins PRs | |
24 | * feat: detect Drone PRs | |
60 | - feat: add Sail CI support | |
61 | - feat: add Buddy support | |
62 | - feat: add Bitrise support | |
63 | - feat: detect Jenkins PRs | |
64 | - feat: detect Drone PRs | |
25 | 65 | |
26 | 66 | ## v1.5.1 |
27 | 67 | |
28 | * fix: use full path to vendors.json | |
68 | - fix: use full path to vendors.json | |
29 | 69 | |
30 | 70 | ## v1.5.0 |
31 | 71 | |
32 | * feat: add dsari detection ([#15](https://github.com/watson/ci-info/pull/15)) | |
33 | * feat: add ci.isPR ([#16](https://github.com/watson/ci-info/pull/16)) | |
72 | - feat: add dsari detection ([#15](https://github.com/watson/ci-info/pull/15)) | |
73 | - feat: add ci.isPR ([#16](https://github.com/watson/ci-info/pull/16)) | |
34 | 74 | |
35 | 75 | ## v1.4.0 |
36 | 76 | |
37 | * feat: add Cirrus CI detection ([#13](https://github.com/watson/ci-info/pull/13)) | |
38 | * feat: add Shippable CI detection ([#14](https://github.com/watson/ci-info/pull/14)) | |
77 | - feat: add Cirrus CI detection ([#13](https://github.com/watson/ci-info/pull/13)) | |
78 | - feat: add Shippable CI detection ([#14](https://github.com/watson/ci-info/pull/14)) | |
39 | 79 | |
40 | 80 | ## v1.3.1 |
41 | 81 | |
42 | * chore: reduce npm package size by not including `.github` folder content ([#11](https://github.com/watson/ci-info/pull/11)) | |
82 | - chore: reduce npm package size by not including `.github` folder content ([#11](https://github.com/watson/ci-info/pull/11)) | |
43 | 83 | |
44 | 84 | ## v1.3.0 |
45 | 85 | |
46 | * feat: add support for Strider CD | |
47 | * chore: deprecate vendor constant `TDDIUM` in favor of `SOLANO` | |
48 | * docs: add missing vendor constant to docs | |
86 | - feat: add support for Strider CD | |
87 | - chore: deprecate vendor constant `TDDIUM` in favor of `SOLANO` | |
88 | - docs: add missing vendor constant to docs | |
49 | 89 | |
50 | 90 | ## v1.2.0 |
51 | 91 | |
52 | * feat: detect solano-ci ([#9](https://github.com/watson/ci-info/pull/9)) | |
92 | - feat: detect solano-ci ([#9](https://github.com/watson/ci-info/pull/9)) | |
53 | 93 | |
54 | 94 | ## v1.1.3 |
55 | 95 | |
56 | * fix: fix spelling of Hunson in `ci.name` | |
96 | - fix: fix spelling of Hunson in `ci.name` | |
57 | 97 | |
58 | 98 | ## v1.1.2 |
59 | 99 | |
60 | * fix: no more false positive matches for Jenkins | |
100 | - fix: no more false positive matches for Jenkins | |
61 | 101 | |
62 | 102 | ## v1.1.1 |
63 | 103 | |
64 | * docs: sort lists of CI servers in README.md | |
65 | * docs: add missing AWS CodeBuild to the docs | |
104 | - docs: sort lists of CI servers in README.md | |
105 | - docs: add missing AWS CodeBuild to the docs | |
66 | 106 | |
67 | 107 | ## v1.1.0 |
68 | 108 | |
69 | * feat: add AWS CodeBuild to CI detection ([#2](https://github.com/watson/ci-info/pull/2)) | |
109 | - feat: add AWS CodeBuild to CI detection ([#2](https://github.com/watson/ci-info/pull/2)) | |
70 | 110 | |
71 | 111 | ## v1.0.1 |
72 | 112 | |
73 | * chore: reduce npm package size by using an `.npmignore` file ([#3](https://github.com/watson/ci-info/pull/3)) | |
113 | - chore: reduce npm package size by using an `.npmignore` file ([#3](https://github.com/watson/ci-info/pull/3)) | |
74 | 114 | |
75 | 115 | ## v1.0.0 |
76 | 116 | |
77 | * Initial release | |
117 | - Initial release |
0 | 0 | The MIT License (MIT) |
1 | 1 | |
2 | Copyright (c) 2016-2018 Thomas Watson Steen | |
2 | Copyright (c) 2016-2021 Thomas Watson Steen | |
3 | 3 | |
4 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy |
5 | 5 | of this software and associated documentation files (the "Software"), to deal |
6 | 6 | if your CI server isn't properly detected :) |
7 | 7 | |
8 | 8 | [![npm](https://img.shields.io/npm/v/ci-info.svg)](https://www.npmjs.com/package/ci-info) |
9 | [![Build status](https://travis-ci.org/watson/ci-info.svg?branch=master)](https://travis-ci.org/watson/ci-info) | |
9 | [![Tests](https://github.com/watson/ci-info/workflows/Tests/badge.svg)](https://github.com/watson/ci-info/actions) | |
10 | 10 | [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard) |
11 | 11 | |
12 | 12 | ## Installation |
31 | 31 | |
32 | 32 | Officially supported CI servers: |
33 | 33 | |
34 | | Name | Constant | isPR | | |
35 | |------|----------|------| | |
36 | | [AWS CodeBuild](https://aws.amazon.com/codebuild/) | `ci.CODEBUILD` | 🚫 | | |
37 | | [AppVeyor](http://www.appveyor.com) | `ci.APPVEYOR` | ✅ | | |
38 | | [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) | `ci.AZURE_PIPELINES` | ✅ | | |
39 | | [Bamboo](https://www.atlassian.com/software/bamboo) by Atlassian | `ci.BAMBOO` | 🚫 | | |
40 | | [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) | `ci.BITBUCKET` | ✅ | | |
41 | | [Bitrise](https://www.bitrise.io/) | `ci.BITRISE` | ✅ | | |
42 | | [Buddy](https://buddy.works/) | `ci.BUDDY` | ✅ | | |
43 | | [Buildkite](https://buildkite.com) | `ci.BUILDKITE` | ✅ | | |
44 | | [CircleCI](http://circleci.com) | `ci.CIRCLE` | ✅ | | |
45 | | [Cirrus CI](https://cirrus-ci.org) | `ci.CIRRUS` | ✅ | | |
46 | | [Codeship](https://codeship.com) | `ci.CODESHIP` | 🚫 | | |
47 | | [Drone](https://drone.io) | `ci.DRONE` | ✅ | | |
48 | | [dsari](https://github.com/rfinnie/dsari) | `ci.DSARI` | 🚫 | | |
49 | | [GitLab CI](https://about.gitlab.com/gitlab-ci/) | `ci.GITLAB` | 🚫 | | |
50 | | [GoCD](https://www.go.cd/) | `ci.GOCD` | 🚫 | | |
51 | | [Hudson](http://hudson-ci.org) | `ci.HUDSON` | 🚫 | | |
52 | | [Jenkins CI](https://jenkins-ci.org) | `ci.JENKINS` | ✅ | | |
53 | | [Magnum CI](https://magnum-ci.com) | `ci.MAGNUM` | 🚫 | | |
54 | | [Netlify CI](https://www.netlify.com/) | `ci.NETLIFY` | ✅ | | |
55 | | [Sail CI](https://sail.ci/) | `ci.SAIL` | ✅ | | |
56 | | [Semaphore](https://semaphoreci.com) | `ci.SEMAPHORE` | ✅ | | |
57 | | [Shippable](https://www.shippable.com/) | `ci.SHIPPABLE` | ✅ | | |
58 | | [Solano CI](https://www.solanolabs.com/) | `ci.SOLANO` | ✅ | | |
59 | | [Strider CD](https://strider-cd.github.io/) | `ci.STRIDER` | 🚫 | | |
60 | | [TaskCluster](http://docs.taskcluster.net) | `ci.TASKCLUSTER` | 🚫 | | |
61 | | [TeamCity](https://www.jetbrains.com/teamcity/) by JetBrains | `ci.TEAMCITY` | 🚫 | | |
62 | | [Travis CI](http://travis-ci.org) | `ci.TRAVIS` | ✅ | | |
34 | | Name | Constant | isPR | | |
35 | | ------------------------------------------------------------------------------- | -------------------- | ---- | | |
36 | | [AWS CodeBuild](https://aws.amazon.com/codebuild/) | `ci.CODEBUILD` | 🚫 | | |
37 | | [AppVeyor](http://www.appveyor.com) | `ci.APPVEYOR` | ✅ | | |
38 | | [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) | `ci.AZURE_PIPELINES` | ✅ | | |
39 | | [Appcircle](https://appcircle.io/) | `ci.APPCIRCLE` | 🚫 | | |
40 | | [Bamboo](https://www.atlassian.com/software/bamboo) by Atlassian | `ci.BAMBOO` | 🚫 | | |
41 | | [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) | `ci.BITBUCKET` | ✅ | | |
42 | | [Bitrise](https://www.bitrise.io/) | `ci.BITRISE` | ✅ | | |
43 | | [Buddy](https://buddy.works/) | `ci.BUDDY` | ✅ | | |
44 | | [Buildkite](https://buildkite.com) | `ci.BUILDKITE` | ✅ | | |
45 | | [CircleCI](http://circleci.com) | `ci.CIRCLE` | ✅ | | |
46 | | [Cirrus CI](https://cirrus-ci.org) | `ci.CIRRUS` | ✅ | | |
47 | | [Codefresh](https://codefresh.io/) | `ci.CODEFRESH` | ✅ | | |
48 | | [Codeship](https://codeship.com) | `ci.CODESHIP` | 🚫 | | |
49 | | [Drone](https://drone.io) | `ci.DRONE` | ✅ | | |
50 | | [dsari](https://github.com/rfinnie/dsari) | `ci.DSARI` | 🚫 | | |
51 | | [GitHub Actions](https://github.com/features/actions/) | `ci.GITHUB_ACTIONS` | ✅ | | |
52 | | [GitLab CI](https://about.gitlab.com/gitlab-ci/) | `ci.GITLAB` | ✅ | | |
53 | | [GoCD](https://www.go.cd/) | `ci.GOCD` | 🚫 | | |
54 | | [Hudson](http://hudson-ci.org) | `ci.HUDSON` | 🚫 | | |
55 | | [Jenkins CI](https://jenkins-ci.org) | `ci.JENKINS` | ✅ | | |
56 | | [LayerCI](https://layerci.com/) | `ci.LAYERCI` | ✅ | | |
57 | | [Magnum CI](https://magnum-ci.com) | `ci.MAGNUM` | 🚫 | | |
58 | | [Netlify CI](https://www.netlify.com/) | `ci.NETLIFY` | ✅ | | |
59 | | [Nevercode](http://nevercode.io/) | `ci.NEVERCODE` | ✅ | | |
60 | | [Render](https://render.com/) | `ci.RENDER` | ✅ | | |
61 | | [Sail CI](https://sail.ci/) | `ci.SAIL` | ✅ | | |
62 | | [Screwdriver](https://screwdriver.cd/) | `ci.SCREWDRIVER` | ✅ | | |
63 | | [Semaphore](https://semaphoreci.com) | `ci.SEMAPHORE` | ✅ | | |
64 | | [Shippable](https://www.shippable.com/) | `ci.SHIPPABLE` | ✅ | | |
65 | | [Solano CI](https://www.solanolabs.com/) | `ci.SOLANO` | ✅ | | |
66 | | [Strider CD](https://strider-cd.github.io/) | `ci.STRIDER` | 🚫 | | |
67 | | [TaskCluster](http://docs.taskcluster.net) | `ci.TASKCLUSTER` | 🚫 | | |
68 | | [TeamCity](https://www.jetbrains.com/teamcity/) by JetBrains | `ci.TEAMCITY` | 🚫 | | |
69 | | [Travis CI](http://travis-ci.org) | `ci.TRAVIS` | ✅ | | |
70 | | [Vercel](https://vercel.com/) | `ci.VERCEL` | 🚫 | | |
71 | | [Visual Studio App Center](https://appcenter.ms/) | `ci.APPCENTER` | 🚫 | | |
63 | 72 | |
64 | 73 | ## API |
65 | 74 |
0 | /** | |
1 | * Returns a boolean. Will be `true` if the code is running on a CI server, | |
2 | * otherwise `false`. | |
3 | * | |
4 | * Some CI servers not listed here might still trigger the `ci.isCI` | |
5 | * boolean to be set to `true` if they use certain vendor neutral environment | |
6 | * variables. In those cases `ci.name` will be `null` and no vendor specific | |
7 | * boolean will be set to `true`. | |
8 | */ | |
9 | export const isCI: boolean; | |
10 | /** | |
11 | * Returns a boolean if PR detection is supported for the current CI server. | |
12 | * Will be `true` if a PR is being tested, otherwise `false`. If PR detection is | |
13 | * not supported for the current CI server, the value will be `null`. | |
14 | */ | |
15 | export const isPR: boolean | null; | |
16 | /** | |
17 | * Returns a string containing name of the CI server the code is running on. If | |
18 | * CI server is not detected, it returns `null`. | |
19 | * | |
20 | * Don't depend on the value of this string not to change for a specific vendor. | |
21 | * If you find your self writing `ci.name === 'Travis CI'`, you most likely want | |
22 | * to use `ci.TRAVIS` instead. | |
23 | */ | |
24 | export const name: string | null; | |
25 | ||
26 | export const APPVEYOR: boolean; | |
27 | export const AZURE_PIPELINES: boolean; | |
28 | export const APPCIRCLE: boolean; | |
29 | export const BAMBOO: boolean; | |
30 | export const BITBUCKET: boolean; | |
31 | export const BITRISE: boolean; | |
32 | export const BUDDY: boolean; | |
33 | export const BUILDKITE: boolean; | |
34 | export const CIRCLE: boolean; | |
35 | export const CIRRUS: boolean; | |
36 | export const CODEBUILD: boolean; | |
37 | export const CODEFRESH: boolean; | |
38 | export const CODESHIP: boolean; | |
39 | export const DRONE: boolean; | |
40 | export const DSARI: boolean; | |
41 | export const GITHUB_ACTIONS: boolean; | |
42 | export const GITLAB: boolean; | |
43 | export const GOCD: boolean; | |
44 | export const HUDSON: boolean; | |
45 | export const JENKINS: boolean; | |
46 | export const LAYERCI: boolean; | |
47 | export const MAGNUM: boolean; | |
48 | export const NETLIFY: boolean; | |
49 | export const NEVERCODE: boolean; | |
50 | export const RENDER: boolean; | |
51 | export const SAIL: boolean; | |
52 | export const SEMAPHORE: boolean; | |
53 | export const SCREWDRIVER: boolean; | |
54 | export const SHIPPABLE: boolean; | |
55 | export const SOLANO: boolean; | |
56 | export const STRIDER: boolean; | |
57 | export const TASKCLUSTER: boolean; | |
58 | export const TEAMCITY: boolean; | |
59 | export const TRAVIS: boolean; | |
60 | export const VERCEL: boolean; | |
61 | export const APPCENTER: boolean; |
0 | 0 | 'use strict' |
1 | 1 | |
2 | var vendors = require('./vendors.json') | |
2 | const vendors = require('./vendors.json') | |
3 | 3 | |
4 | var env = process.env | |
4 | const env = process.env | |
5 | 5 | |
6 | 6 | // Used for testing only |
7 | 7 | Object.defineProperty(exports, '_vendors', { |
12 | 12 | exports.isPR = null |
13 | 13 | |
14 | 14 | vendors.forEach(function (vendor) { |
15 | var envs = Array.isArray(vendor.env) ? vendor.env : [vendor.env] | |
16 | var isCI = envs.every(function (obj) { | |
15 | const envs = Array.isArray(vendor.env) ? vendor.env : [vendor.env] | |
16 | const isCI = envs.every(function (obj) { | |
17 | 17 | return checkEnv(obj) |
18 | 18 | }) |
19 | 19 |
0 | root = true | |
1 | ||
2 | [*] | |
3 | indent_style = tab | |
4 | end_of_line = lf | |
5 | charset = utf-8 | |
6 | trim_trailing_whitespace = true | |
7 | insert_final_newline = true | |
8 | ||
9 | [*.yml] | |
10 | indent_style = space | |
11 | indent_size = 2 |
0 | package-lock=false |
0 | export interface Options { | |
1 | /** | |
2 | The stream to check. | |
3 | ||
4 | @default process.stdout | |
5 | */ | |
6 | readonly stream?: NodeJS.WritableStream; | |
7 | } | |
8 | ||
9 | /** | |
10 | Check if stdout or stderr is [interactive](https://unix.stackexchange.com/a/43389/7678). | |
11 | ||
12 | It checks that the stream is [TTY](https://jameshfisher.com/2017/12/09/what-is-a-tty/), not a dumb terminal, and not running in a CI. | |
13 | ||
14 | This can be useful to decide whether to present interactive UI or animations in the terminal. | |
15 | ||
16 | @example | |
17 | ``` | |
18 | import isInteractive from 'is-interactive'; | |
19 | ||
20 | isInteractive(); | |
21 | //=> true | |
22 | ``` | |
23 | */ | |
24 | export default function isInteractive(options?: Options): boolean; |
0 | export default function isInteractive({stream = process.stdout} = {}) { | |
1 | return Boolean( | |
2 | stream && stream.isTTY && | |
3 | process.env.TERM !== 'dumb' && | |
4 | !('CI' in process.env) | |
5 | ); | |
6 | } |
0 | import {expectType} from 'tsd'; | |
1 | import isInteractive from './index.js'; | |
2 | ||
3 | expectType<boolean>(isInteractive({ | |
4 | stream: process.stderr | |
5 | })); |
0 | MIT License | |
1 | ||
2 | Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com) | |
3 | ||
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
5 | ||
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
7 | ||
8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
0 | { | |
1 | "name": "is-interactive", | |
2 | "version": "2.0.0", | |
3 | "description": "Check if stdout or stderr is interactive", | |
4 | "license": "MIT", | |
5 | "repository": "sindresorhus/is-interactive", | |
6 | "funding": "https://github.com/sponsors/sindresorhus", | |
7 | "author": { | |
8 | "name": "Sindre Sorhus", | |
9 | "email": "sindresorhus@gmail.com", | |
10 | "url": "https://sindresorhus.com" | |
11 | }, | |
12 | "type": "module", | |
13 | "exports": "./index.js", | |
14 | "engines": { | |
15 | "node": ">=12" | |
16 | }, | |
17 | "scripts": { | |
18 | "test": "xo && ava && tsd" | |
19 | }, | |
20 | "files": [ | |
21 | "index.js", | |
22 | "index.d.ts" | |
23 | ], | |
24 | "keywords": [ | |
25 | "interactive", | |
26 | "stdout", | |
27 | "stderr", | |
28 | "detect", | |
29 | "is", | |
30 | "terminal", | |
31 | "shell", | |
32 | "tty" | |
33 | ], | |
34 | "devDependencies": { | |
35 | "@types/node": "^15.0.1", | |
36 | "ava": "^3.15.0", | |
37 | "tsd": "^0.14.0", | |
38 | "xo": "^0.39.1" | |
39 | } | |
40 | } |
0 | # is-interactive | |
1 | ||
2 | > Check if stdout or stderr is [interactive](https://unix.stackexchange.com/a/43389/7678) | |
3 | ||
4 | It checks that the stream is [TTY](https://jameshfisher.com/2017/12/09/what-is-a-tty/), not a dumb terminal, and not running in a CI. | |
5 | ||
6 | This can be useful to decide whether to present interactive UI or animations in the terminal. | |
7 | ||
8 | ## Install | |
9 | ||
10 | ``` | |
11 | $ npm install is-interactive | |
12 | ``` | |
13 | ||
14 | ## Usage | |
15 | ||
16 | ```js | |
17 | import isInteractive from 'is-interactive'; | |
18 | ||
19 | isInteractive(); | |
20 | //=> true | |
21 | ``` | |
22 | ||
23 | ## API | |
24 | ||
25 | ### isInteractive(options?) | |
26 | ||
27 | #### options | |
28 | ||
29 | Type: `object` | |
30 | ||
31 | ##### stream | |
32 | ||
33 | Type: [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable)\ | |
34 | Default: [`process.stdout`](https://nodejs.org/api/process.html#process_process_stdout) | |
35 | ||
36 | The stream to check. | |
37 | ||
38 | ## FAQ | |
39 | ||
40 | #### Why are you not using [`ci-info`](https://github.com/watson/ci-info) for the CI check? | |
41 | ||
42 | It's silly to have to detect individual CIs. They should identify themselves with the `CI` environment variable, and most do just that. A manually maintained list of detections will easily get out of date. And if a package using `ci-info` doesn't update to the latest version all the time, they will not support certain CIs. It also creates unpredictability as you might assume a CI is not supported and then suddenly it gets supported and you didn't account for that. In addition, some of the manual detections are loose and might cause false-positives which could create hard-to-debug bugs. | |
43 | ||
44 | #### Why does this even exist? It's just a few lines. | |
45 | ||
46 | It's not about the number of lines, but rather discoverability and documentation. A lot of people wouldn't even know they need this. Feel free to copy-paste the code if you don't want the dependency. You might also want to read [this blog post](https://blog.sindresorhus.com/small-focused-modules-9238d977a92a). | |
47 | ||
48 | ## Related | |
49 | ||
50 | - [is-unicode-supported](https://github.com/sindresorhus/is-unicode-supported) - Detect whether the terminal supports Unicode | |
51 | - [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color |
0 | import {PassThrough as PassThroughStream} from 'node:stream'; | |
1 | import test from 'ava'; | |
2 | import isInteractive from './index.js'; | |
3 | ||
4 | test('tty', t => { | |
5 | const ci = process.env.CI; | |
6 | delete process.env.CI; | |
7 | const stream = new PassThroughStream(); | |
8 | stream.isTTY = true; | |
9 | t.true(isInteractive({stream})); | |
10 | process.env.CI = ci; | |
11 | }); | |
12 | ||
13 | test('non-tty', t => { | |
14 | const stream = new PassThroughStream(); | |
15 | stream.isTTY = false; | |
16 | t.false(isInteractive({stream})); | |
17 | }); | |
18 | ||
19 | test('dumb', t => { | |
20 | const term = process.env.TERM; | |
21 | process.env.TERM = 'dumb'; | |
22 | t.false(isInteractive()); | |
23 | process.env.TERM = term; | |
24 | }); |
0 | 0 | { |
1 | 1 | "name": "ci-info", |
2 | "version": "2.0.0", | |
2 | "version": "3.2.0", | |
3 | 3 | "description": "Get details about the current Continuous Integration environment", |
4 | 4 | "main": "index.js", |
5 | "dependencies": {}, | |
6 | "devDependencies": { | |
7 | "clear-require": "^1.0.1", | |
8 | "standard": "^12.0.1", | |
9 | "tape": "^4.9.1" | |
10 | }, | |
11 | "scripts": { | |
12 | "test": "standard && node test.js" | |
13 | }, | |
5 | "typings": "index.d.ts", | |
6 | "author": "Thomas Watson Steen <w@tson.dk> (https://twitter.com/wa7son)", | |
7 | "license": "MIT", | |
14 | 8 | "repository": { |
15 | 9 | "type": "git", |
16 | 10 | "url": "https://github.com/watson/ci-info.git" |
17 | 11 | }, |
12 | "bugs": { | |
13 | "url": "https://github.com/watson/ci-info/issues" | |
14 | }, | |
15 | "homepage": "https://github.com/watson/ci-info", | |
18 | 16 | "keywords": [ |
19 | 17 | "ci", |
20 | 18 | "continuous", |
22 | 20 | "test", |
23 | 21 | "detect" |
24 | 22 | ], |
25 | "author": "Thomas Watson Steen <w@tson.dk> (https://twitter.com/wa7son)", | |
26 | "license": "MIT", | |
27 | "bugs": { | |
28 | "url": "https://github.com/watson/ci-info/issues" | |
29 | }, | |
30 | "homepage": "https://github.com/watson/ci-info", | |
31 | 23 | "coordinates": [ |
32 | 24 | 55.778231, |
33 | 25 | 12.593179 |
34 | ] | |
26 | ], | |
27 | "scripts": { | |
28 | "test": "standard && node test.js" | |
29 | }, | |
30 | "devDependencies": { | |
31 | "clear-module": "^4.1.1", | |
32 | "standard": "^16.0.3", | |
33 | "tape": "^5.2.2" | |
34 | } | |
35 | 35 | } |
0 | 0 | 'use strict' |
1 | 1 | |
2 | var test = require('tape') | |
3 | var clearRequire = require('clear-require') | |
4 | ||
5 | var isActualPR = !!(process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') | |
2 | const test = require('tape') | |
3 | const clearModule = require('clear-module') | |
4 | ||
5 | const isActualPR = !!(process.env.GITHUB_EVENT_NAME && process.env.GITHUB_EVENT_NAME === 'pull_request') | |
6 | 6 | |
7 | 7 | test('Known CI', function (t) { |
8 | process.env.TRAVIS = 'true' | |
9 | ||
10 | var ci = require('./') | |
8 | process.env.GITHUB_ACTIONS = 'true' | |
9 | ||
10 | const ci = require('./') | |
11 | 11 | |
12 | 12 | t.ok(Array.isArray(ci._vendors)) |
13 | 13 | t.ok(ci._vendors.length > 0) |
14 | 14 | |
15 | 15 | t.equal(ci.isCI, true) |
16 | 16 | t.equal(ci.isPR, isActualPR) |
17 | t.equal(ci.name, 'Travis CI') | |
18 | t.equal(ci.TRAVIS, true) | |
19 | assertVendorConstants('TRAVIS', ci, t) | |
17 | t.equal(ci.name, 'GitHub Actions') | |
18 | t.equal(ci.GITHUB_ACTIONS, true) | |
19 | assertVendorConstants('GITHUB_ACTIONS', ci, t) | |
20 | 20 | |
21 | 21 | t.end() |
22 | 22 | }) |
26 | 26 | delete process.env.CONTINUOUS_INTEGRATION |
27 | 27 | delete process.env.BUILD_NUMBER |
28 | 28 | delete process.env.TRAVIS |
29 | ||
30 | clearRequire('./') | |
31 | var ci = require('./') | |
29 | delete process.env.GITHUB_ACTIONS | |
30 | ||
31 | clearModule('./') | |
32 | const ci = require('./') | |
32 | 33 | |
33 | 34 | t.equal(ci.isCI, false) |
34 | 35 | t.equal(ci.isPR, null) |
42 | 43 | test('Unknown CI', function (t) { |
43 | 44 | process.env.CI = 'true' |
44 | 45 | |
45 | clearRequire('./') | |
46 | var ci = require('./') | |
46 | clearModule('./') | |
47 | const ci = require('./') | |
47 | 48 | |
48 | 49 | t.equal(ci.isCI, true) |
49 | 50 | t.equal(ci.isPR, null) |
58 | 59 | process.env.APPVEYOR = 'true' |
59 | 60 | process.env.APPVEYOR_PULL_REQUEST_NUMBER = '42' |
60 | 61 | |
61 | clearRequire('./') | |
62 | var ci = require('./') | |
62 | clearModule('./') | |
63 | const ci = require('./') | |
63 | 64 | |
64 | 65 | t.equal(ci.isCI, true) |
65 | 66 | t.equal(ci.isPR, true) |
76 | 77 | test('AppVeyor - Not PR', function (t) { |
77 | 78 | process.env.APPVEYOR = 'true' |
78 | 79 | |
79 | clearRequire('./') | |
80 | var ci = require('./') | |
80 | clearModule('./') | |
81 | const ci = require('./') | |
81 | 82 | |
82 | 83 | t.equal(ci.isCI, true) |
83 | 84 | t.equal(ci.isPR, false) |
94 | 95 | process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI = 'https://dev.azure.com/Contoso' |
95 | 96 | process.env.SYSTEM_PULLREQUEST_PULLREQUESTID = '42' |
96 | 97 | |
97 | clearRequire('./') | |
98 | var ci = require('./') | |
98 | clearModule('./') | |
99 | const ci = require('./') | |
99 | 100 | |
100 | 101 | t.equal(ci.isCI, true) |
101 | 102 | t.equal(ci.isPR, true) |
112 | 113 | test('Azure Pipelines - Not PR', function (t) { |
113 | 114 | process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI = 'https://dev.azure.com/Contoso' |
114 | 115 | |
115 | clearRequire('./') | |
116 | var ci = require('./') | |
116 | clearModule('./') | |
117 | const ci = require('./') | |
117 | 118 | |
118 | 119 | t.equal(ci.isCI, true) |
119 | 120 | t.equal(ci.isPR, false) |
130 | 131 | process.env.BITBUCKET_COMMIT = 'true' |
131 | 132 | process.env.BITBUCKET_PR_ID = '42' |
132 | 133 | |
133 | clearRequire('./') | |
134 | var ci = require('./') | |
134 | clearModule('./') | |
135 | const ci = require('./') | |
135 | 136 | |
136 | 137 | t.equal(ci.isCI, true) |
137 | 138 | t.equal(ci.isPR, true) |
148 | 149 | test('Bitbucket Pipelines - Not PR', function (t) { |
149 | 150 | process.env.BITBUCKET_COMMIT = 'true' |
150 | 151 | |
151 | clearRequire('./') | |
152 | var ci = require('./') | |
152 | clearModule('./') | |
153 | const ci = require('./') | |
153 | 154 | |
154 | 155 | t.equal(ci.isCI, true) |
155 | 156 | t.equal(ci.isPR, false) |
166 | 167 | process.env.BUILDKITE = 'true' |
167 | 168 | process.env.BUILDKITE_PULL_REQUEST = '42' |
168 | 169 | |
169 | clearRequire('./') | |
170 | var ci = require('./') | |
170 | clearModule('./') | |
171 | const ci = require('./') | |
171 | 172 | |
172 | 173 | t.equal(ci.isCI, true) |
173 | 174 | t.equal(ci.isPR, true) |
185 | 186 | process.env.BUILDKITE = 'true' |
186 | 187 | process.env.BUILDKITE_PULL_REQUEST = 'false' |
187 | 188 | |
188 | clearRequire('./') | |
189 | var ci = require('./') | |
189 | clearModule('./') | |
190 | const ci = require('./') | |
190 | 191 | |
191 | 192 | t.equal(ci.isCI, true) |
192 | 193 | t.equal(ci.isPR, false) |
204 | 205 | process.env.CIRCLECI = 'true' |
205 | 206 | process.env.CIRCLE_PULL_REQUEST = '42' |
206 | 207 | |
207 | clearRequire('./') | |
208 | var ci = require('./') | |
208 | clearModule('./') | |
209 | const ci = require('./') | |
209 | 210 | |
210 | 211 | t.equal(ci.isCI, true) |
211 | 212 | t.equal(ci.isPR, true) |
222 | 223 | test('CircleCI - Not PR', function (t) { |
223 | 224 | process.env.CIRCLECI = 'true' |
224 | 225 | |
225 | clearRequire('./') | |
226 | var ci = require('./') | |
226 | clearModule('./') | |
227 | const ci = require('./') | |
227 | 228 | |
228 | 229 | t.equal(ci.isCI, true) |
229 | 230 | t.equal(ci.isPR, false) |
240 | 241 | process.env.CIRRUS_CI = 'true' |
241 | 242 | process.env.CIRRUS_PR = '42' |
242 | 243 | |
243 | clearRequire('./') | |
244 | var ci = require('./') | |
244 | clearModule('./') | |
245 | const ci = require('./') | |
245 | 246 | |
246 | 247 | t.equal(ci.isCI, true) |
247 | 248 | t.equal(ci.isPR, true) |
258 | 259 | test('Cirrus CI - Not PR', function (t) { |
259 | 260 | process.env.CIRRUS_CI = 'true' |
260 | 261 | |
261 | clearRequire('./') | |
262 | var ci = require('./') | |
262 | clearModule('./') | |
263 | const ci = require('./') | |
263 | 264 | |
264 | 265 | t.equal(ci.isCI, true) |
265 | 266 | t.equal(ci.isPR, false) |
272 | 273 | t.end() |
273 | 274 | }) |
274 | 275 | |
276 | test('Codefresh - PR', function (t) { | |
277 | process.env.CF_BUILD_ID = 'true' | |
278 | process.env.CF_PULL_REQUEST_ID = '42' | |
279 | ||
280 | clearModule('./') | |
281 | const ci = require('./') | |
282 | ||
283 | t.equal(ci.isCI, true) | |
284 | t.equal(ci.isPR, true) | |
285 | t.equal(ci.name, 'Codefresh') | |
286 | t.equal(ci.CODEFRESH, true) | |
287 | assertVendorConstants('CODEFRESH', ci, t) | |
288 | ||
289 | delete process.env.CF_BUILD_ID | |
290 | delete process.env.CF_PULL_REQUEST_ID | |
291 | ||
292 | t.end() | |
293 | }) | |
294 | ||
295 | test('Codefresh - Not PR', function (t) { | |
296 | process.env.CF_BUILD_ID = 'true' | |
297 | ||
298 | clearModule('./') | |
299 | const ci = require('./') | |
300 | ||
301 | t.equal(ci.isCI, true) | |
302 | t.equal(ci.isPR, false) | |
303 | t.equal(ci.name, 'Codefresh') | |
304 | t.equal(ci.CODEFRESH, true) | |
305 | assertVendorConstants('CODEFRESH', ci, t) | |
306 | ||
307 | delete process.env.CF_BUILD_ID | |
308 | ||
309 | t.end() | |
310 | }) | |
311 | ||
312 | test('LayerCI - PR', function (t) { | |
313 | process.env.LAYERCI = 'true' | |
314 | process.env.LAYERCI_PULL_REQUEST = 'https://link-to-pr/5' | |
315 | ||
316 | clearModule('./') | |
317 | const ci = require('./') | |
318 | ||
319 | t.equal(ci.isCI, true) | |
320 | t.equal(ci.isPR, true) | |
321 | t.equal(ci.name, 'LayerCI') | |
322 | t.equal(ci.LAYERCI, true) | |
323 | assertVendorConstants('LAYERCI', ci, t) | |
324 | ||
325 | delete process.env.LAYERCI | |
326 | delete process.env.LAYERCI_PULL_REQUEST | |
327 | ||
328 | t.end() | |
329 | }) | |
330 | ||
331 | test('LayerCI - Not PR', function (t) { | |
332 | process.env.LAYERCI = 'true' | |
333 | ||
334 | clearModule('./') | |
335 | const ci = require('./') | |
336 | ||
337 | t.equal(ci.isCI, true) | |
338 | t.equal(ci.isPR, false) | |
339 | t.equal(ci.name, 'LayerCI') | |
340 | t.equal(ci.LAYERCI, true) | |
341 | assertVendorConstants('LAYERCI', ci, t) | |
342 | ||
343 | delete process.env.LAYERCI | |
344 | ||
345 | t.end() | |
346 | }) | |
347 | ||
348 | test('Appcircle', function (t) { | |
349 | process.env.AC_APPCIRCLE = 'true' | |
350 | ||
351 | clearModule('./') | |
352 | const ci = require('./') | |
353 | ||
354 | t.equal(ci.isCI, true) | |
355 | t.equal(ci.name, 'Appcircle') | |
356 | t.equal(ci.APPCIRCLE, true) | |
357 | assertVendorConstants('APPCIRCLE', ci, t) | |
358 | ||
359 | delete process.env.AC_APPCIRCLE | |
360 | ||
361 | t.end() | |
362 | }) | |
363 | ||
364 | test('Render - PR', function (t) { | |
365 | process.env.RENDER = 'true' | |
366 | process.env.IS_PULL_REQUEST = 'true' | |
367 | ||
368 | clearModule('./') | |
369 | const ci = require('./') | |
370 | ||
371 | t.equal(ci.isCI, true) | |
372 | t.equal(ci.isPR, true) | |
373 | t.equal(ci.name, 'Render') | |
374 | t.equal(ci.RENDER, true) | |
375 | assertVendorConstants('RENDER', ci, t) | |
376 | ||
377 | delete process.env.RENDER | |
378 | delete process.env.IS_PULL_REQUEST | |
379 | ||
380 | t.end() | |
381 | }) | |
382 | ||
383 | test('Render - Not PR', function (t) { | |
384 | process.env.RENDER = 'true' | |
385 | process.env.IS_PULL_REQUEST = 'false' | |
386 | ||
387 | clearModule('./') | |
388 | const ci = require('./') | |
389 | ||
390 | t.equal(ci.isCI, true) | |
391 | t.equal(ci.isPR, false) | |
392 | t.equal(ci.name, 'Render') | |
393 | t.equal(ci.RENDER, true) | |
394 | assertVendorConstants('RENDER', ci, t) | |
395 | ||
396 | delete process.env.RENDER | |
397 | delete process.env.IS_PULL_REQUEST | |
398 | ||
399 | t.end() | |
400 | }) | |
401 | ||
275 | 402 | test('Semaphore - PR', function (t) { |
276 | 403 | process.env.SEMAPHORE = 'true' |
277 | 404 | process.env.PULL_REQUEST_NUMBER = '42' |
278 | 405 | |
279 | clearRequire('./') | |
280 | var ci = require('./') | |
406 | clearModule('./') | |
407 | const ci = require('./') | |
281 | 408 | |
282 | 409 | t.equal(ci.isCI, true) |
283 | 410 | t.equal(ci.isPR, true) |
294 | 421 | test('Semaphore - Not PR', function (t) { |
295 | 422 | process.env.SEMAPHORE = 'true' |
296 | 423 | |
297 | clearRequire('./') | |
298 | var ci = require('./') | |
424 | clearModule('./') | |
425 | const ci = require('./') | |
299 | 426 | |
300 | 427 | t.equal(ci.isCI, true) |
301 | 428 | t.equal(ci.isPR, false) |
312 | 439 | process.env.SHIPPABLE = 'true' |
313 | 440 | process.env.IS_PULL_REQUEST = 'true' |
314 | 441 | |
315 | clearRequire('./') | |
316 | var ci = require('./') | |
442 | clearModule('./') | |
443 | const ci = require('./') | |
317 | 444 | |
318 | 445 | t.equal(ci.isCI, true) |
319 | 446 | t.equal(ci.isPR, true) |
331 | 458 | process.env.SHIPPABLE = 'true' |
332 | 459 | process.env.IS_PULL_REQUEST = 'false' |
333 | 460 | |
334 | clearRequire('./') | |
335 | var ci = require('./') | |
461 | clearModule('./') | |
462 | const ci = require('./') | |
336 | 463 | |
337 | 464 | t.equal(ci.isCI, true) |
338 | 465 | t.equal(ci.isPR, false) |
350 | 477 | process.env.TDDIUM = 'true' |
351 | 478 | process.env.TDDIUM_PR_ID = '42' |
352 | 479 | |
353 | clearRequire('./') | |
354 | var ci = require('./') | |
480 | clearModule('./') | |
481 | const ci = require('./') | |
355 | 482 | |
356 | 483 | t.equal(ci.isCI, true) |
357 | 484 | t.equal(ci.isPR, true) |
368 | 495 | test('Solano CI - Not PR', function (t) { |
369 | 496 | process.env.TDDIUM = 'true' |
370 | 497 | |
371 | clearRequire('./') | |
372 | var ci = require('./') | |
498 | clearModule('./') | |
499 | const ci = require('./') | |
373 | 500 | |
374 | 501 | t.equal(ci.isCI, true) |
375 | 502 | t.equal(ci.isPR, false) |
386 | 513 | process.env.TRAVIS = 'true' |
387 | 514 | process.env.TRAVIS_PULL_REQUEST = '42' |
388 | 515 | |
389 | clearRequire('./') | |
390 | var ci = require('./') | |
516 | clearModule('./') | |
517 | const ci = require('./') | |
391 | 518 | |
392 | 519 | t.equal(ci.isCI, true) |
393 | 520 | t.equal(ci.isPR, true) |
405 | 532 | process.env.TRAVIS = 'true' |
406 | 533 | process.env.TRAVIS_PULL_REQUEST = 'false' |
407 | 534 | |
408 | clearRequire('./') | |
409 | var ci = require('./') | |
535 | clearModule('./') | |
536 | const ci = require('./') | |
410 | 537 | |
411 | 538 | t.equal(ci.isCI, true) |
412 | 539 | t.equal(ci.isPR, false) |
421 | 548 | }) |
422 | 549 | |
423 | 550 | test('Netlify CI - PR', function (t) { |
424 | process.env.NETLIFY_BUILD_BASE = '/opt/build' | |
551 | process.env.NETLIFY = 'true' | |
425 | 552 | process.env.PULL_REQUEST = 'true' |
426 | 553 | |
427 | clearRequire('./') | |
428 | var ci = require('./') | |
554 | clearModule('./') | |
555 | const ci = require('./') | |
429 | 556 | |
430 | 557 | t.equal(ci.isCI, true) |
431 | 558 | t.equal(ci.isPR, true) |
433 | 560 | t.equal(ci.NETLIFY, true) |
434 | 561 | assertVendorConstants('NETLIFY', ci, t) |
435 | 562 | |
436 | delete process.env.NETLIFY_BUILD_BASE | |
563 | delete process.env.NETLIFY | |
437 | 564 | delete process.env.PULL_REQUEST |
438 | 565 | |
439 | 566 | t.end() |
440 | 567 | }) |
441 | 568 | |
442 | 569 | test('Netlify CI - Not PR', function (t) { |
443 | process.env.NETLIFY_BUILD_BASE = '/opt/build' | |
570 | process.env.NETLIFY = 'true' | |
444 | 571 | process.env.PULL_REQUEST = 'false' |
445 | 572 | |
446 | clearRequire('./') | |
447 | var ci = require('./') | |
573 | clearModule('./') | |
574 | const ci = require('./') | |
448 | 575 | |
449 | 576 | t.equal(ci.isCI, true) |
450 | 577 | t.equal(ci.isPR, false) |
452 | 579 | t.equal(ci.NETLIFY, true) |
453 | 580 | assertVendorConstants('NETLIFY', ci, t) |
454 | 581 | |
455 | delete process.env.NETLIFY_BUILD_BASE | |
582 | delete process.env.NETLIFY | |
456 | 583 | delete process.env.PULL_REQUEST |
584 | ||
585 | t.end() | |
586 | }) | |
587 | ||
588 | test('Vercel', function (t) { | |
589 | process.env.NOW_BUILDER = '1' | |
590 | ||
591 | clearModule('./') | |
592 | const ci = require('./') | |
593 | ||
594 | t.equal(ci.isCI, true) | |
595 | t.equal(ci.isPR, null) | |
596 | t.equal(ci.name, 'Vercel') | |
597 | t.equal(ci.VERCEL, true) | |
598 | assertVendorConstants('VERCEL', ci, t) | |
599 | ||
600 | delete process.env.NOW_BUILDER | |
601 | ||
602 | t.end() | |
603 | }) | |
604 | ||
605 | test('Nevercode - PR', function (t) { | |
606 | process.env.NEVERCODE = 'true' | |
607 | process.env.NEVERCODE_PULL_REQUEST = 'true' | |
608 | ||
609 | clearModule('./') | |
610 | const ci = require('./') | |
611 | ||
612 | t.equal(ci.isCI, true) | |
613 | t.equal(ci.isPR, true) | |
614 | t.equal(ci.name, 'Nevercode') | |
615 | t.equal(ci.NEVERCODE, true) | |
616 | assertVendorConstants('NEVERCODE', ci, t) | |
617 | ||
618 | delete process.env.NEVERCODE | |
619 | delete process.env.NEVERCODE_PULL_REQUEST | |
620 | ||
621 | t.end() | |
622 | }) | |
623 | ||
624 | test('Nevercode - Not PR', function (t) { | |
625 | process.env.NEVERCODE = 'true' | |
626 | process.env.NEVERCODE_PULL_REQUEST = 'false' | |
627 | ||
628 | clearModule('./') | |
629 | const ci = require('./') | |
630 | ||
631 | t.equal(ci.isCI, true) | |
632 | t.equal(ci.isPR, false) | |
633 | t.equal(ci.name, 'Nevercode') | |
634 | t.equal(ci.NEVERCODE, true) | |
635 | assertVendorConstants('NEVERCODE', ci, t) | |
636 | ||
637 | delete process.env.NEVERCODE | |
638 | delete process.env.NEVERCODE_PULL_REQUEST | |
639 | ||
640 | t.end() | |
641 | }) | |
642 | ||
643 | test('GitHub Actions - PR', function (t) { | |
644 | process.env.GITHUB_ACTIONS = 'true' | |
645 | process.env.GITHUB_EVENT_NAME = 'pull_request' | |
646 | ||
647 | clearModule('./') | |
648 | const ci = require('./') | |
649 | ||
650 | t.equal(ci.isCI, true) | |
651 | t.equal(ci.isPR, true) | |
652 | t.equal(ci.name, 'GitHub Actions') | |
653 | t.equal(ci.GITHUB_ACTIONS, true) | |
654 | assertVendorConstants('GITHUB_ACTIONS', ci, t) | |
655 | ||
656 | delete process.env.GITHUB_ACTIONS | |
657 | delete process.env.GITHUB_EVENT_NAME | |
658 | ||
659 | t.end() | |
660 | }) | |
661 | ||
662 | test('GitHub Actions - Not PR', function (t) { | |
663 | process.env.GITHUB_ACTIONS = 'true' | |
664 | process.env.GITHUB_EVENT_NAME = 'push' | |
665 | ||
666 | clearModule('./') | |
667 | const ci = require('./') | |
668 | ||
669 | t.equal(ci.isCI, true) | |
670 | t.equal(ci.isPR, false) | |
671 | t.equal(ci.name, 'GitHub Actions') | |
672 | t.equal(ci.GITHUB_ACTIONS, true) | |
673 | assertVendorConstants('GITHUB_ACTIONS', ci, t) | |
674 | ||
675 | delete process.env.GITHUB_ACTIONS | |
676 | delete process.env.GITHUB_EVENT_NAME | |
677 | ||
678 | t.end() | |
679 | }) | |
680 | ||
681 | test('Screwdriver - PR', function (t) { | |
682 | process.env.SCREWDRIVER = 'true' | |
683 | process.env.SD_PULL_REQUEST = '1' | |
684 | ||
685 | clearModule('./') | |
686 | const ci = require('./') | |
687 | ||
688 | t.equal(ci.isCI, true) | |
689 | t.equal(ci.isPR, true) | |
690 | t.equal(ci.name, 'Screwdriver') | |
691 | t.equal(ci.SCREWDRIVER, true) | |
692 | assertVendorConstants('SCREWDRIVER', ci, t) | |
693 | ||
694 | delete process.env.SCREWDRIVER | |
695 | delete process.env.SD_PULL_REQUEST | |
696 | ||
697 | t.end() | |
698 | }) | |
699 | ||
700 | test('Screwdriver - Not PR', function (t) { | |
701 | process.env.SCREWDRIVER = 'true' | |
702 | process.env.SD_PULL_REQUEST = 'false' | |
703 | ||
704 | clearModule('./') | |
705 | const ci = require('./') | |
706 | ||
707 | t.equal(ci.isCI, true) | |
708 | t.equal(ci.isPR, false) | |
709 | t.equal(ci.name, 'Screwdriver') | |
710 | t.equal(ci.SCREWDRIVER, true) | |
711 | assertVendorConstants('SCREWDRIVER', ci, t) | |
712 | ||
713 | delete process.env.SCREWDRIVER | |
714 | delete process.env.SD_PULL_REQUEST | |
715 | ||
716 | t.end() | |
717 | }) | |
718 | ||
719 | test('Visual Studio App Center', function (t) { | |
720 | process.env.APPCENTER_BUILD_ID = '1' | |
721 | ||
722 | clearModule('./') | |
723 | const ci = require('./') | |
724 | ||
725 | t.equal(ci.isCI, true) | |
726 | // t.equal(ci.isPR, false) | |
727 | t.equal(ci.name, 'Visual Studio App Center') | |
728 | t.equal(ci.APPCENTER, true) | |
729 | assertVendorConstants('APPCENTER', ci, t) | |
730 | ||
731 | delete process.env.APPCENTER | |
457 | 732 | |
458 | 733 | t.end() |
459 | 734 | }) |
460 | 735 | |
461 | 736 | function assertVendorConstants (expect, ci, t) { |
462 | 737 | ci._vendors.forEach(function (constant) { |
463 | var bool = constant === expect | |
738 | let bool = constant === expect | |
464 | 739 | bool = (expect === 'SOLANO' && constant === 'TDDIUM') || bool // support deprecated option |
465 | 740 | t.equal(ci[constant], bool, 'ci.' + constant) |
466 | 741 | }) |
0 | MIT License | |
1 | ||
2 | Copyright (c) Microsoft Corporation. All rights reserved. | |
3 | ||
4 | Permission is hereby granted, free of charge, to any person obtaining a copy | |
5 | of this software and associated documentation files (the "Software"), to deal | |
6 | in the Software without restriction, including without limitation the rights | |
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
8 | copies of the Software, and to permit persons to whom the Software is | |
9 | furnished to do so, subject to the following conditions: | |
10 | ||
11 | The above copyright notice and this permission notice shall be included in all | |
12 | copies or substantial portions of the Software. | |
13 | ||
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
20 | SOFTWARE | |
0 | MIT License | |
1 | ||
2 | Copyright (c) Microsoft Corporation. | |
3 | ||
4 | Permission is hereby granted, free of charge, to any person obtaining a copy | |
5 | of this software and associated documentation files (the "Software"), to deal | |
6 | in the Software without restriction, including without limitation the rights | |
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
8 | copies of the Software, and to permit persons to whom the Software is | |
9 | furnished to do so, subject to the following conditions: | |
10 | ||
11 | The above copyright notice and this permission notice shall be included in all | |
12 | copies or substantial portions of the Software. | |
13 | ||
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
20 | SOFTWARE |
0 | # Installation | |
1 | > `npm install --save @types/ci-info` | |
2 | ||
3 | # Summary | |
4 | This package contains type definitions for ci-info ( https://github.com/watson/ci-info ). | |
5 | ||
6 | # Details | |
7 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ci-info | |
8 | ||
9 | Additional Details | |
10 | * Last updated: Thu, 30 May 2019 19:18:07 GMT | |
11 | * Dependencies: none | |
12 | * Global values: none | |
13 | ||
14 | # Credits | |
15 | These definitions were written by Florian Keller <https://github.com/ffflorian>. | |
0 | This is a stub types definition for @types/ci-info (https://github.com/watson/ci-info). | |
1 | ||
2 | ci-info provides its own type definitions, so you don't need @types/ci-info installed!⏎ |
0 | // Type definitions for ci-info 2.0 | |
1 | // Project: https://github.com/watson/ci-info | |
2 | // Definitions by: Florian Keller <https://github.com/ffflorian> | |
3 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | |
4 | ||
5 | /** | |
6 | * Returns a boolean. Will be `true` if the code is running on a CI server, | |
7 | * otherwise `false`. | |
8 | * | |
9 | * Some CI servers not listed here might still trigger the `ci.isCI` | |
10 | * boolean to be set to `true` if they use certain vendor neutral environment | |
11 | * variables. In those cases `ci.name` will be `null` and no vendor specific | |
12 | * boolean will be set to `true`. | |
13 | */ | |
14 | export const isCI: boolean; | |
15 | /** | |
16 | * Returns a boolean if PR detection is supported for the current CI server. | |
17 | * Will be `true` if a PR is being tested, otherwise `false`. If PR detection is | |
18 | * not supported for the current CI server, the value will be `null`. | |
19 | */ | |
20 | export const isPR: boolean | null; | |
21 | /** | |
22 | * Returns a string containing name of the CI server the code is running on. If | |
23 | * CI server is not detected, it returns `null`. | |
24 | * | |
25 | * Don't depend on the value of this string not to change for a specific vendor. | |
26 | * If you find your self writing `ci.name === 'Travis CI'`, you most likely want | |
27 | * to use `ci.TRAVIS` instead. | |
28 | */ | |
29 | export const name: string | null; | |
30 | ||
31 | export const APPVEYOR: boolean; | |
32 | export const AZURE_PIPELINES: boolean; | |
33 | export const BAMBOO: boolean; | |
34 | export const BITBUCKET: boolean; | |
35 | export const BITRISE: boolean; | |
36 | export const BUDDY: boolean; | |
37 | export const BUILDKITE: boolean; | |
38 | export const CIRCLE: boolean; | |
39 | export const CIRRUS: boolean; | |
40 | export const CODEBUILD: boolean; | |
41 | export const CODESHIP: boolean; | |
42 | export const DRONE: boolean; | |
43 | export const DSARI: boolean; | |
44 | export const GITLAB: boolean; | |
45 | export const GOCD: boolean; | |
46 | export const HUDSON: boolean; | |
47 | export const JENKINS: boolean; | |
48 | export const MAGNUM: boolean; | |
49 | export const NETLIFY: boolean; | |
50 | export const SAIL: boolean; | |
51 | export const SEMAPHORE: boolean; | |
52 | export const SHIPPABLE: boolean; | |
53 | export const SOLANO: boolean; | |
54 | export const STRIDER: boolean; | |
55 | export const TASKCLUSTER: boolean; | |
56 | export const TEAMCITY: boolean; | |
57 | export const TRAVIS: boolean; |
0 | 0 | { |
1 | 1 | "name": "@types/ci-info", |
2 | "version": "2.0.0", | |
3 | "description": "TypeScript definitions for ci-info", | |
2 | "version": "3.1.0", | |
3 | "typings": null, | |
4 | "description": "Stub TypeScript definitions entry for ci-info, which provides its own types definitions", | |
5 | "main": "", | |
6 | "scripts": {}, | |
7 | "author": "", | |
4 | 8 | "license": "MIT", |
5 | "contributors": [ | |
6 | { | |
7 | "name": "Florian Keller", | |
8 | "url": "https://github.com/ffflorian", | |
9 | "githubUsername": "ffflorian" | |
10 | } | |
11 | ], | |
12 | "main": "", | |
13 | "types": "index", | |
14 | "repository": { | |
15 | "type": "git", | |
16 | "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", | |
17 | "directory": "types/ci-info" | |
18 | }, | |
19 | "scripts": {}, | |
20 | "dependencies": {}, | |
21 | "typesPublisherContentHash": "e6c493e61b2974ff40875edce1616a42e098b7792efea9c9e3eb433ccdecbaae", | |
22 | "typeScriptVersion": "2.0" | |
9 | "dependencies": { | |
10 | "ci-info": "*" | |
11 | } | |
23 | 12 | }⏎ |
11 | 11 | "pr": "SYSTEM_PULLREQUEST_PULLREQUESTID" |
12 | 12 | }, |
13 | 13 | { |
14 | "name": "Appcircle", | |
15 | "constant": "APPCIRCLE", | |
16 | "env": "AC_APPCIRCLE" | |
17 | }, | |
18 | { | |
14 | 19 | "name": "Bamboo", |
15 | 20 | "constant": "BAMBOO", |
16 | 21 | "env": "bamboo_planKey" |
57 | 62 | "env": "CODEBUILD_BUILD_ARN" |
58 | 63 | }, |
59 | 64 | { |
65 | "name": "Codefresh", | |
66 | "constant": "CODEFRESH", | |
67 | "env": "CF_BUILD_ID", | |
68 | "pr": { "any": ["CF_PULL_REQUEST_NUMBER", "CF_PULL_REQUEST_ID"] } | |
69 | }, | |
70 | { | |
60 | 71 | "name": "Codeship", |
61 | 72 | "constant": "CODESHIP", |
62 | 73 | "env": { "CI_NAME": "codeship" } |
73 | 84 | "env": "DSARI" |
74 | 85 | }, |
75 | 86 | { |
87 | "name": "GitHub Actions", | |
88 | "constant": "GITHUB_ACTIONS", | |
89 | "env": "GITHUB_ACTIONS", | |
90 | "pr": { "GITHUB_EVENT_NAME": "pull_request" } | |
91 | }, | |
92 | { | |
76 | 93 | "name": "GitLab CI", |
77 | 94 | "constant": "GITLAB", |
78 | "env": "GITLAB_CI" | |
95 | "env": "GITLAB_CI", | |
96 | "pr": "CI_MERGE_REQUEST_ID" | |
79 | 97 | }, |
80 | 98 | { |
81 | 99 | "name": "GoCD", |
82 | 100 | "constant": "GOCD", |
83 | 101 | "env": "GO_PIPELINE_LABEL" |
102 | }, | |
103 | { | |
104 | "name": "LayerCI", | |
105 | "constant": "LAYERCI", | |
106 | "env": "LAYERCI", | |
107 | "pr": "LAYERCI_PULL_REQUEST" | |
84 | 108 | }, |
85 | 109 | { |
86 | 110 | "name": "Hudson", |
101 | 125 | { |
102 | 126 | "name": "Netlify CI", |
103 | 127 | "constant": "NETLIFY", |
104 | "env": "NETLIFY_BUILD_BASE", | |
128 | "env": "NETLIFY", | |
105 | 129 | "pr": { "env": "PULL_REQUEST", "ne": "false" } |
130 | }, | |
131 | { | |
132 | "name": "Nevercode", | |
133 | "constant": "NEVERCODE", | |
134 | "env": "NEVERCODE", | |
135 | "pr": { "env": "NEVERCODE_PULL_REQUEST", "ne": "false" } | |
136 | }, | |
137 | { | |
138 | "name": "Render", | |
139 | "constant": "RENDER", | |
140 | "env": "RENDER", | |
141 | "pr": { "IS_PULL_REQUEST": "true" } | |
106 | 142 | }, |
107 | 143 | { |
108 | 144 | "name": "Sail CI", |
117 | 153 | "pr": "PULL_REQUEST_NUMBER" |
118 | 154 | }, |
119 | 155 | { |
156 | "name": "Screwdriver", | |
157 | "constant": "SCREWDRIVER", | |
158 | "env": "SCREWDRIVER", | |
159 | "pr": { "env": "SD_PULL_REQUEST", "ne": "false" } | |
160 | }, | |
161 | { | |
120 | 162 | "name": "Shippable", |
121 | 163 | "constant": "SHIPPABLE", |
122 | 164 | "env": "SHIPPABLE", |
148 | 190 | "constant": "TRAVIS", |
149 | 191 | "env": "TRAVIS", |
150 | 192 | "pr": { "env": "TRAVIS_PULL_REQUEST", "ne": "false" } |
193 | }, | |
194 | { | |
195 | "name": "Vercel", | |
196 | "constant": "VERCEL", | |
197 | "env": "NOW_BUILDER" | |
198 | }, | |
199 | { | |
200 | "name": "Visual Studio App Center", | |
201 | "constant": "APPCENTER", | |
202 | "env": "APPCENTER_BUILD_ID" | |
151 | 203 | } |
152 | 204 | ] |