UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

1 lines 2.27 kB
{"version":3,"sources":["../../../packages/tools/wac-cli/src/angular15/upgrader/file-replacement-upgrader.ts"],"names":[],"mappings":"AAIA,qBAAa,uBAAuB;IAChC,OAAO,CAAC,qBAAqB,CAAS;IACtC,OAAO,CAAC,eAAe,CAAS;IAEhC,OAAO,CAAC,QAAQ,CAGd;IAEF;;;;;OAKG;gBACS,qBAAqB,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAQrF;;OAEG;IACU,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAmBpC","file":"file-replacement-upgrader.d.ts","sourcesContent":["import { pathExists } from 'fs-extra';\r\nimport { Logger } from '../utils/logger';\r\nimport { fileReplacement } from '../utils/file-replacement';\r\n\r\nexport class FileReplacementUpgrader {\r\n private sourceContentFilePath: string;\r\n private writeToFilePath: string;\r\n\r\n private messages = {\r\n notFound: '',\r\n sourceFileNotFound: ''\r\n };\r\n\r\n /**\r\n * the constructor.\r\n * @param sourceContentFilePath the source file path.\r\n * @param writeToFilePath the write to file path.\r\n * @param fileName the file name.\r\n */\r\n constructor(sourceContentFilePath: string, writeToFilePath: string, fileName?: string) {\r\n this.sourceContentFilePath = sourceContentFilePath;\r\n this.writeToFilePath = writeToFilePath;\r\n\r\n this.messages.notFound = `${fileName} writeToFilePath not found at ${this.writeToFilePath}.`\r\n this.messages.sourceFileNotFound = `${fileName} sourceContentFilePath not found at ${this.sourceContentFilePath}.`\r\n }\r\n\r\n /**\r\n * the run function to resolve the errors.\r\n */\r\n public async run(): Promise<void> {\r\n try {\r\n const exists = await pathExists(this.sourceContentFilePath);\r\n const writeToFilePathExists = await pathExists(this.writeToFilePath);\r\n\r\n if (!exists) {\r\n Logger.log(this.messages.sourceFileNotFound);\r\n }\r\n\r\n if (!writeToFilePathExists) {\r\n Logger.log(this.messages.notFound);\r\n }\r\n if (exists && writeToFilePathExists) {\r\n await fileReplacement(this.sourceContentFilePath, this.writeToFilePath)\r\n }\r\n } catch (error) {\r\n Logger.error(error);\r\n }\r\n }\r\n}\r\n"]}