UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

47 lines (45 loc) 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GitIgnoreUpgrader = void 0; const fs_extra_1 = require("fs-extra"); const logger_1 = require("../utils/logger"); const file_writer_1 = require("../utils/file-writer"); const git_ignore_config_1 = require("../configs/git-ignore-config"); class GitIgnoreUpgrader { fileName = '.gitignore'; 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(git_ignore_config_1.adds, true, 0, '') .writeFile(); } else { logger_1.Logger.log(this.messages.notFound); } } catch (error) { logger_1.Logger.error(error); } } } exports.GitIgnoreUpgrader = GitIgnoreUpgrader; //# sourceMappingURL=git-ignore-upgrader.js.map