UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

54 lines (52 loc) 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VersionJsonUpgrader = void 0; const fs_extra_1 = require("fs-extra"); const logger_1 = require("../utils/logger"); const file_writer_1 = require("../utils/file-writer"); const replace_config_1 = require("../configs/replace-config"); /** * The upgrader for the version.ts */ class VersionJsonUpgrader { fileName = 'version.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); // guarantee the version is 4.x if (!this.fileWriter.getData().includes('"version": "4')) { this.fileWriter .tabToTwoSpaces() .replaceVersion(replace_config_1.versionJsonReplaces) .writeFile(); } } else { logger_1.Logger.log(this.messages.notFound); } } catch (error) { logger_1.Logger.error(error); } } } exports.VersionJsonUpgrader = VersionJsonUpgrader; //# sourceMappingURL=version-json-upgrader.js.map