Skip to content

Instantly share code, notes, and snippets.

@arabold
Created April 13, 2020 02:12
Show Gist options
  • Save arabold/81ead1687423bb4ae86200ae3e779b82 to your computer and use it in GitHub Desktop.
Save arabold/81ead1687423bb4ae86200ae3e779b82 to your computer and use it in GitHub Desktop.
/** Returns `true` if running in a CI environment, e.g. during an automated build */
static get isCI(): boolean {
if (!Logger.isNode) {
return false;
}
const { CI, CONTINUOUS_INTEGRATION, BUILD_NUMBER, RUN_ID } = process.env;
// Shamelessly stolen from https://github.com/watson/ci-info
return !!(
CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari
CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI
BUILD_NUMBER || // Jenkins, TeamCity
RUN_ID || // TaskCluster, dsari
false
);
}
/** Retruns `true` if running as part of a unit test */
static get isUnitTest(): boolean {
if (!Logger.isNode) {
return false;
}
const { JEST_WORKER_ID } = process.env;
return !!(JEST_WORKER_ID || typeof global?.it === "function");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment