UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

47 lines (45 loc) 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CIBuildYmlUpgrader = void 0; const fs_extra_1 = require("fs-extra"); const logger_1 = require("../utils/logger"); const file_writer_1 = require("../utils/file-writer"); const ci_build_yml_config_1 = require("../configs/ci-build-yml-config"); class CIBuildYmlUpgrader { filePath; fileWriter; messages = { notFound: '' }; /** * the constructor. * @param filePath the file path. * @param fileName the file name. */ constructor(filePath, fileName) { this.filePath = filePath; this.messages.notFound = `${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 .replaceContent(ci_build_yml_config_1.replaces) .writeFile(); } else { logger_1.Logger.log(this.messages.notFound); } } catch (error) { logger_1.Logger.error(error); } } } exports.CIBuildYmlUpgrader = CIBuildYmlUpgrader; //# sourceMappingURL=ci-build-yml-upgrader.js.map