approvals
Version:
Approval Tests Library - Capturing Human Intelligence
38 lines (37 loc) • 1.36 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReportLaunchingCircuitBreaker = void 0;
const FinalMessages_1 = require("../FinalMessages");
const nodediffReporter_1 = __importDefault(require("./Reporters/nodediffReporter"));
let maxLaunch = 10;
let currentCount = 0;
let reroutedCount = 0;
class ReportLaunchingCircuitBreaker {
static setMaxLaunch(value) {
maxLaunch = value;
}
static get currentCount() {
return currentCount;
}
static notifyLaunched() {
currentCount++;
}
static isLimitExceeded() {
return maxLaunch <= currentCount;
}
static check(approved, received, options) {
if (this.isLimitExceeded()) {
reroutedCount++;
FinalMessages_1.FinalMessages.addKeyMessage("maxLaunches", `config.maxLaunches (${maxLaunch}) exceeded: ${reroutedCount} diff(s) shown in console above...`);
new nodediffReporter_1.default().report(approved, received, options);
return true;
}
this.notifyLaunched();
return false;
}
}
exports.ReportLaunchingCircuitBreaker = ReportLaunchingCircuitBreaker;
exports.default = ReportLaunchingCircuitBreaker;