From 24cc4506b79226e8f524276d00e876d432cd6a87 Mon Sep 17 00:00:00 2001 From: Pascal Jufer Date: Mon, 2 Jan 2023 10:48:09 +0100 Subject: [PATCH] fix: bypass isCI checks with 'CI' env set to `false` (#101) --- index.js | 5 +++-- test.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index e91c518..4790726 100644 --- a/index.js +++ b/index.js @@ -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 @@ -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) { diff --git a/test.js b/test.js index d914489..2552ef7 100644 --- a/test.js +++ b/test.js @@ -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'