vtex
Version:
The platform for e-commerce apps
23 lines (22 loc) • 1.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeatureFlagUpdateChecker = void 0;
const path_1 = require("path");
const spawnUnblockingChildProcess_1 = require("../../lib/utils/spawnUnblockingChildProcess");
const featureFlag_1 = require("../../api/modules/featureFlag");
class FeatureFlagUpdateChecker {
static checkForUpdateFeatureFlag() {
if (FeatureFlagUpdateChecker.shouldUpdateFeatureFlagFile()) {
FeatureFlagUpdateChecker.startUpdateFileProcess();
}
}
static shouldUpdateFeatureFlagFile() {
const invervalFromLastUpdate = Date.now() - featureFlag_1.FeatureFlag.getSingleton().getLastFeatureFlagUpdate();
return invervalFromLastUpdate >= FeatureFlagUpdateChecker.FEATURE_FLAG_CHECK_INTERVAL;
}
static startUpdateFileProcess() {
spawnUnblockingChildProcess_1.spawnUnblockingChildProcess(process.execPath, [path_1.join(__dirname, 'featureFlagUpdateExec.js')]);
}
}
exports.FeatureFlagUpdateChecker = FeatureFlagUpdateChecker;
FeatureFlagUpdateChecker.FEATURE_FLAG_CHECK_INTERVAL = 1000 * 60 * 2; // 2 Minutes