UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

68 lines (66 loc) 2.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TSConfigUpgrader = void 0; const fs_extra_1 = require("fs-extra"); const logger_1 = require("../utils/logger"); const file_writer_1 = require("../utils/file-writer"); const tsconfig_config_1 = require("../configs/tsconfig-config"); class TSConfigUpgrader { 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 for base config. */ async runBase() { try { const exists = await (0, fs_extra_1.pathExists)(this.filePath); if (exists) { this.fileWriter = new file_writer_1.FileWriter(this.filePath); this.fileWriter .replaceTsConfigContent(tsconfig_config_1.baseReplaces) .replaceContent(tsconfig_config_1.baseDirectReplaces) .writeFile(); } else { logger_1.Logger.log(this.messages.notFound); } } catch (error) { logger_1.Logger.error(error); } } /** * 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 .replaceTsConfigContent(tsconfig_config_1.replaces) .writeFile(); } else { logger_1.Logger.log(this.messages.notFound); } } catch (error) { logger_1.Logger.error(error); } } } exports.TSConfigUpgrader = TSConfigUpgrader; //# sourceMappingURL=tsconfig-upgrader.js.map