UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

43 lines (41 loc) 1.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ParameterCountViolationUpdater = void 0; const common_1 = require("../../../common"); const logger_1 = require("../../utils/logger"); const iif_updater_util_1 = require("./iif-updater-util"); const subjuct_next_updater_util_1 = require("./subjuct-next-updater-util"); /** * the ParameterCountViolationUpdater error handler/updater. */ class ParameterCountViolationUpdater { /** * 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 errorLineContent = fileData.split('\n')[error.position.line - 1]; let result = fileData; logger_1.Logger.log('line content: ' + errorLineContent); if (errorLineContent.includes('iif')) { const updater = new iif_updater_util_1.IiFUpdaterUtil(); result = updater.update(fileData, error); } else if (errorLineContent.includes('next')) { const updater = new subjuct_next_updater_util_1.SubjectNextUpdaterUtil(); result = updater.update(fileData, error); } else { logger_1.Logger.log('Found no updater for this error: ' + JSON.stringify(error)); } error.resolved = common_1.ResolveState.Resolved; return new Promise(resolve => resolve(result)); } } exports.ParameterCountViolationUpdater = ParameterCountViolationUpdater; //# sourceMappingURL=parameter-count-violation-updater.js.map