UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

52 lines (50 loc) 1.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AngularJsonUpgrader = void 0; const fs_extra_1 = require("fs-extra"); const logger_1 = require("../utils/logger"); const file_writer_1 = require("../utils/file-writer"); const angular_json_config_1 = require("../configs/angular-json-config"); /** * the angular.json upgrader class. */ class AngularJsonUpgrader { fileName = 'angular.json'; filePath; fileWriter; messages = { notFound: '' }; /** * the constructor. * @param filePath the file path. */ constructor(filePath) { this.filePath = filePath; this.messages.notFound = `${this.fileName} not found at ${this.filePath}.`; } /** * the run function to resolve the errors. */ async run() { try { const exists = await (0, fs_extra_1.pathExists)(this.filePath); if (exists) { this.fileWriter = new file_writer_1.FileWriter(this.filePath); this.fileWriter .addContent(angular_json_config_1.adds) .removeContent(angular_json_config_1.removes) .replaceContent(angular_json_config_1.replaces) .writeFile(); } else { logger_1.Logger.log(this.messages.notFound); } } catch (error) { logger_1.Logger.error(error); } } } exports.AngularJsonUpgrader = AngularJsonUpgrader; //# sourceMappingURL=angular-json-upgrader.js.map