Skip to content

Commit

Permalink
fix: bypass isCI checks with 'CI' env set to false (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
paescuj committed Jan 2, 2023
1 parent 29e5da6 commit 24cc450
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ vendors.forEach(function (vendor) {
})

exports.isCI = !!(
env.BUILD_ID || // Jenkins, Cloudbees
env.CI !== 'false' && // Bypass all checks if CI env is explicitly set to 'false'
(env.BUILD_ID || // Jenkins, Cloudbees
env.BUILD_NUMBER || // Jenkins, TeamCity
env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari
env.CI_APP_ID || // Appflow
Expand All @@ -64,7 +65,7 @@ exports.isCI = !!(
env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI
env.RUN_ID || // TaskCluster, dsari
exports.name ||
false
false)
)

function checkEnv (obj) {
Expand Down
11 changes: 11 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ test('Not CI', function (t) {
t.end()
})

test('Bypass isCI checks with CI set to `false`', function (t) {
process.env.CI = 'false'

clearModule('./')
const ci = require('./')

t.equal(ci.isCI, false)

t.end()
})

test('Unknown CI', function (t) {
process.env.CI = 'true'

Expand Down

0 comments on commit 24cc450

Please sign in to comment.