├── .github └── workflows │ └── tests.yml ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── bin.js ├── index.d.ts ├── index.js ├── package.json └── test.js /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | strategy: 10 | matrix: 11 | node-version: [8, 10, 12, 14, 16, 17] 12 | 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Use Node.js ${{ matrix.node-version }} 16 | uses: actions/setup-node@v4 17 | with: 18 | node-version: ${{ matrix.node-version }} 19 | - run: npm install 20 | - run: npm test 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### Bower ### 2 | bower_components 3 | .bower-cache 4 | .bower-registry 5 | .bower-tmp 6 | 7 | ### grunt ### 8 | # Grunt usually compiles files inside this directory 9 | dist/ 10 | 11 | # Grunt usually preprocesses files such as coffeescript, compass... inside the .tmp directory 12 | .tmp/ 13 | 14 | ### Linux ### 15 | *~ 16 | 17 | # temporary files which can be created if a process still has a handle open of a deleted file 18 | .fuse_hidden* 19 | 20 | # KDE directory preferences 21 | .directory 22 | 23 | # Linux trash folder which might appear on any partition or disk 24 | .Trash-* 25 | 26 | # .nfs files are created when an open file is removed but is still being accessed 27 | .nfs* 28 | 29 | ### macOS ### 30 | # General 31 | .DS_Store 32 | .AppleDouble 33 | .LSOverride 34 | 35 | # Icon must end with two \r 36 | Icon 37 | 38 | 39 | # Thumbnails 40 | ._* 41 | 42 | # Files that might appear in the root of a volume 43 | .DocumentRevisions-V100 44 | .fseventsd 45 | .Spotlight-V100 46 | .TemporaryItems 47 | .Trashes 48 | .VolumeIcon.icns 49 | .com.apple.timemachine.donotpresent 50 | 51 | # Directories potentially created on remote AFP share 52 | .AppleDB 53 | .AppleDesktop 54 | Network Trash Folder 55 | Temporary Items 56 | .apdisk 57 | 58 | ### Node ### 59 | # Logs 60 | logs 61 | *.log 62 | npm-debug.log* 63 | yarn-debug.log* 64 | yarn-error.log* 65 | lerna-debug.log* 66 | 67 | # Diagnostic reports (https://nodejs.org/api/report.html) 68 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 69 | 70 | # Runtime data 71 | pids 72 | *.pid 73 | *.seed 74 | *.pid.lock 75 | 76 | # Directory for instrumented libs generated by jscoverage/JSCover 77 | lib-cov 78 | 79 | # Coverage directory used by tools like istanbul 80 | coverage 81 | *.lcov 82 | 83 | # nyc test coverage 84 | .nyc_output 85 | 86 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 87 | .grunt 88 | 89 | # Bower dependency directory (https://bower.io/) 90 | 91 | # node-waf configuration 92 | .lock-wscript 93 | 94 | # Compiled binary addons (https://nodejs.org/api/addons.html) 95 | build/Release 96 | 97 | # Dependency directories 98 | node_modules/ 99 | jspm_packages/ 100 | 101 | # TypeScript v1 declaration files 102 | typings/ 103 | 104 | # TypeScript cache 105 | *.tsbuildinfo 106 | 107 | # Optional npm cache directory 108 | .npm 109 | 110 | # Optional eslint cache 111 | .eslintcache 112 | 113 | # Optional stylelint cache 114 | .stylelintcache 115 | 116 | # Microbundle cache 117 | .rpt2_cache/ 118 | .rts2_cache_cjs/ 119 | .rts2_cache_es/ 120 | .rts2_cache_umd/ 121 | 122 | # Optional REPL history 123 | .node_repl_history 124 | 125 | # Output of 'npm pack' 126 | *.tgz 127 | 128 | # Yarn Integrity file 129 | .yarn-integrity 130 | 131 | # dotenv environment variables file 132 | .env 133 | .env.test 134 | .env*.local 135 | 136 | # parcel-bundler cache (https://parceljs.org/) 137 | .cache 138 | .parcel-cache 139 | 140 | # Next.js build output 141 | .next 142 | 143 | # Nuxt.js build / generate output 144 | .nuxt 145 | dist 146 | 147 | # Gatsby files 148 | .cache/ 149 | # Comment in the public line in if your project uses Gatsby and not Next.js 150 | # https://nextjs.org/blog/next-9-1#public-directory-support 151 | # public 152 | 153 | # vuepress build output 154 | .vuepress/dist 155 | 156 | # Serverless directories 157 | .serverless/ 158 | 159 | # FuseBox cache 160 | .fusebox/ 161 | 162 | # DynamoDB Local files 163 | .dynamodb/ 164 | 165 | # TernJS port file 166 | .tern-port 167 | 168 | # Stores VSCode versions used for testing VSCode extensions 169 | .vscode-test 170 | 171 | ### Sass ### 172 | .sass-cache/ 173 | *.css.map 174 | *.sass.map 175 | *.scss.map 176 | 177 | ### Windows ### 178 | # Windows thumbnail cache files 179 | Thumbs.db 180 | Thumbs.db:encryptable 181 | ehthumbs.db 182 | ehthumbs_vista.db 183 | 184 | # Dump file 185 | *.stackdump 186 | 187 | # Folder config file 188 | [Dd]esktop.ini 189 | 190 | # Recycle Bin used on file shares 191 | $RECYCLE.BIN/ 192 | 193 | # Windows Installer files 194 | *.cab 195 | *.msi 196 | *.msix 197 | *.msm 198 | *.msp 199 | 200 | # Windows shortcuts 201 | *.lnk 202 | 203 | ### yarn ### 204 | # https://yarnpkg.com/advanced/qa#which-files-should-be-gitignored 205 | 206 | .yarn/* 207 | !.yarn/releases 208 | !.yarn/plugins 209 | !.yarn/sdks 210 | !.yarn/versions 211 | 212 | # if you are NOT using Zero-installs, then: 213 | # comment the following lines 214 | !.yarn/cache 215 | 216 | # and uncomment the following lines 217 | # .pnp.* 218 | 219 | package-lock.json 220 | yarn.lock 221 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .travis.yml 2 | test.js 3 | .github 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## v4.1.0 4 | 5 | - add `types` ([116335d](https://github.com/watson/is-ci/commit/116335d)) 6 | 7 | ## v4.0.0 8 | 9 | - update to `ci-info` v4 ([658c179](https://github.com/watson/is-ci/commit/658c179)) 10 | 11 | ## v3.0.1 12 | 13 | - remove `.github` folder from published files ([dd15229](https://github.com/watson/is-ci/commit/dd15229)) 14 | 15 | ## v3.0.0 16 | 17 | Breaking changes: 18 | 19 | - update to `ci-info` v3. This drops support for EOL node versions 6, 13 20 | 21 | ## v2.0.0 22 | 23 | Breaking changes: 24 | 25 | - Drop support for Node.js end-of-life versions: 0.10, 0.12, 4, 5, 7, 26 | and 9 27 | 28 | Other changes: 29 | 30 | See [ci-info 31 | changelog](https://github.com/watson/ci-info/blob/master/CHANGELOG.md#v200) 32 | for a list of newly supported CI servers. 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2021 Thomas Watson Steen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # is-ci 2 | 3 | Returns `true` if the current environment is a Continuous Integration 4 | server. 5 | 6 | Please [open an issue](https://github.com/watson/is-ci/issues) if your 7 | CI server isn't properly detected :) 8 | 9 | [![npm](https://img.shields.io/npm/v/is-ci.svg)](https://www.npmjs.com/package/is-ci) 10 | [![Tests](https://github.com/watson/is-ci/workflows/Tests/badge.svg)](https://github.com/watson/is-ci/actions) 11 | [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard) 12 | 13 | ## Installation 14 | 15 | ```bash 16 | npm install is-ci --save 17 | ``` 18 | 19 | ## Programmatic Usage 20 | 21 | ```js 22 | const isCI = require('is-ci') 23 | 24 | if (isCI) { 25 | console.log('The code is running on a CI server') 26 | } 27 | ``` 28 | 29 | ## CLI Usage 30 | 31 | For CLI usage you need to have the `is-ci` executable in your `PATH`. 32 | There's a few ways to do that: 33 | 34 | - Either install the module globally using `npm install is-ci -g` 35 | - Or add the module as a dependency to your app in which case it can be 36 | used inside your package.json scripts as is 37 | - Or provide the full path to the executable, e.g. 38 | `./node_modules/.bin/is-ci` 39 | 40 | ```bash 41 | is-ci && echo "This is a CI server" 42 | ``` 43 | 44 | ## Supported CI tools 45 | 46 | Refer to [ci-info](https://github.com/watson/ci-info#supported-ci-tools) docs for all supported CI's 47 | 48 | ## License 49 | 50 | [MIT](LICENSE) 51 | -------------------------------------------------------------------------------- /bin.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict' 3 | 4 | process.exit(require('./') ? 0 : 1) 5 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | import { isCI } from "ci-info"; 2 | 3 | export = isCI; 4 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = require('ci-info').isCI 4 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "is-ci", 3 | "version": "4.1.0", 4 | "description": "Detect if the current environment is a CI server", 5 | "bin": "bin.js", 6 | "type": "commonjs", 7 | "main": "index.js", 8 | "types": "index.d.ts", 9 | "author": "Thomas Watson Steen (https://twitter.com/wa7son)", 10 | "license": "MIT", 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/watson/is-ci.git" 14 | }, 15 | "bugs": { 16 | "url": "https://github.com/watson/is-ci/issues" 17 | }, 18 | "homepage": "https://github.com/watson/is-ci", 19 | "contributors": [ 20 | { 21 | "name": "Thomas Watson", 22 | "url": "https://github.com/watson" 23 | }, 24 | { 25 | "name": "Sibiraj", 26 | "url": "https://github.com/sibiraj-s" 27 | } 28 | ], 29 | "funding": [ 30 | { 31 | "type": "github", 32 | "url": "https://github.com/sponsors/sibiraj-s" 33 | } 34 | ], 35 | "keywords": [ 36 | "ci", 37 | "continuous", 38 | "integration", 39 | "test", 40 | "detect" 41 | ], 42 | "coordinates": [ 43 | 55.778272, 44 | 12.593116 45 | ], 46 | "scripts": { 47 | "test": "standard && node test.js" 48 | }, 49 | "dependencies": { 50 | "ci-info": "^4.1.0" 51 | }, 52 | "devDependencies": { 53 | "clear-module": "^4.1.2", 54 | "standard": "^17.1.2" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const assert = require('assert') 4 | const clearModule = require('clear-module') 5 | 6 | process.env.CI = 'true' 7 | 8 | let isCI = require('./') 9 | assert(isCI) 10 | 11 | delete process.env.CI 12 | delete process.env.CONTINUOUS_INTEGRATION 13 | delete process.env.BUILD_NUMBER 14 | delete process.env.TRAVIS 15 | delete process.env.GITHUB_ACTIONS 16 | 17 | clearModule('./') 18 | clearModule('ci-info') 19 | isCI = require('./') 20 | assert(!isCI) 21 | --------------------------------------------------------------------------------