UNPKG

pcf-scripts

Version:

This package contains a module for building PowerApps Component Framework (PCF) controls. See project homepage how to install.

36 lines (34 loc) 1.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FeatureManager = void 0; const fs_1 = require("fs"); const path_1 = require("path"); const process_1 = require("process"); const constants = require("./constants"); // eslint-disable-next-line @typescript-eslint/no-require-imports const buildFlags = require("./featureflags.json"); class FeatureManager { constructor() { const configPath = (0, path_1.join)((0, process_1.cwd)(), constants.FEATURE_CONFIG_FILE_NAME); let featureOverrides = {}; try { // fs doesn't exist on pcf-start, so check for undefined if ((0, fs_1.existsSync)?.(configPath)) { const featureConfig = (0, fs_1.readFileSync)(configPath, "utf8"); featureOverrides = JSON.parse(featureConfig); } } catch (error) { console.error(`[FeatureManager] [Error] Error reading feature configuration from ${configPath}:\n${error}`); } this._featureFlags = Object.entries(buildFlags).reduce((acc, [key, value]) => { acc[key] = featureOverrides[key] ?? value; return acc; }, {}); } isFeatureEnabled(feature) { return this._featureFlags[feature] === "on"; } } exports.FeatureManager = FeatureManager; //# sourceMappingURL=featureManager.js.map