UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

44 lines (42 loc) 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LoadChildrenCallbackUpdater = void 0; const common_1 = require("../../../common"); const logger_1 = require("../../utils/logger"); /** * Updater for LoadChildrenCallback errors. */ class LoadChildrenCallbackUpdater { /** * the update function. * @param fileData the file data. * @param error the error object. * @returns the updated file data. */ update(fileData, error) { if (!fileData) { logger_1.Logger.error(`Cannot find file data`); } const result = this.regexFixer(fileData); error.resolved = common_1.ResolveState.Resolved; return new Promise(resolve => resolve(result)); } /** * the update function. * @param inputString the input file data string. * @returns the updated file data string. */ regexFixer(inputString) { const regexPattern = /loadChildren:\s*'([^#']+#[^']+)'/; if (regexPattern.test(inputString)) { const replacedString = inputString.replace(regexPattern, (_match, modulePath) => { const [moduleFile, moduleName] = modulePath.split('#'); return `loadChildren: () => import('${moduleFile}').then(m => m.${moduleName})`; }); return replacedString; } return inputString; } } exports.LoadChildrenCallbackUpdater = LoadChildrenCallbackUpdater; //# sourceMappingURL=load-children-callback-updater.js.map