@knapsack-pro/core
Version:
Knapsack Pro Core library splits tests across CI nodes and makes sure that tests will run in optimal time on each CI node. This library gives core features like communication with KnapsackPro.com API. This library is a dependency for other projects specif
58 lines (57 loc) • 1.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CIEnvConfig = exports.isCI = exports.detectCI = void 0;
const ci_providers_1 = require("../ci-providers");
const detectCI = () => {
const detected = [
ci_providers_1.AppVeyor,
ci_providers_1.Buildkite,
ci_providers_1.CircleCI,
ci_providers_1.CirrusCI,
ci_providers_1.CodefreshCI,
ci_providers_1.Codeship,
ci_providers_1.GithubActions,
ci_providers_1.GitlabCI,
ci_providers_1.HerokuCI,
ci_providers_1.SemaphoreCI,
ci_providers_1.SemaphoreCI2,
ci_providers_1.TravisCI,
]
.map((provider) => provider.detect)
.filter(Boolean)[0];
return detected || ci_providers_1.UnsupportedCI;
};
exports.detectCI = detectCI;
const isCI = () => (process.env.CI || 'false').toLowerCase() === 'true' ||
(0, exports.detectCI)() !== ci_providers_1.UnsupportedCI;
exports.isCI = isCI;
class CIEnvConfig {
static get ciNodeTotal() {
return this.ciEnvFor('ciNodeTotal');
}
static get ciNodeIndex() {
return this.ciEnvFor('ciNodeIndex');
}
static get ciNodeBuildId() {
return this.ciEnvFor('ciNodeBuildId');
}
static get ciNodeRetryCount() {
return this.ciEnvFor('ciNodeRetryCount');
}
static get commitHash() {
return this.ciEnvFor('commitHash');
}
static get branch() {
return this.ciEnvFor('branch');
}
static get userSeat() {
return this.ciEnvFor('userSeat');
}
static get fixedQueueSplit() {
return this.ciEnvFor('fixedQueueSplit');
}
static ciEnvFor(functionName) {
return (0, exports.detectCI)()[functionName];
}
}
exports.CIEnvConfig = CIEnvConfig;