diff --git a/tools/office-cmdlet-updater/config/default.json b/tools/office-cmdlet-updater/config/default.json index 11eecdda01..a77f1ebf6a 100644 --- a/tools/office-cmdlet-updater/config/default.json +++ b/tools/office-cmdlet-updater/config/default.json @@ -1,14 +1,20 @@ { - "platyPS": { - "docPath": "..\\..\\teams\\teams-ps\\teams" - }, - "sendgrid": { - "sendMailNotification": false, - "apiKey": "", - "emailSettings": { - "from": "no-replay@outlook.com", - "to": "test@gmail.com", - "subject": "Test subject" - } -} + "platyPS": { + "docs": [ + { + "name": "teams", + "path": "..\\..\\teams\\teams-ps\\teams" + } + ], + "ignoreFiles": [] + }, + "sendgrid": { + "sendMailNotification": false, + "apiKey": "", + "emailSettings": { + "from": "no-replay@outlook.com", + "to": "test@gmail.com", + "subject": "Test subject" + } + } } diff --git a/tools/office-cmdlet-updater/controllers/markdown.controller.js b/tools/office-cmdlet-updater/controllers/markdown.controller.js index 481ed370fb..d3c241a747 100644 --- a/tools/office-cmdlet-updater/controllers/markdown.controller.js +++ b/tools/office-cmdlet-updater/controllers/markdown.controller.js @@ -11,11 +11,7 @@ class MarkdownController { async updateMarkdown() { let err; - const { docPath } = this.config.get('platyPS'); - - if (!await fs.pathExists(docPath)) { - throw new Error(powerShellErrors.DOC_PATH_DOESNT_EXIST); - } + const { docs } = this.config.get('platyPS'); [, err] = await of(this.powerShellService.preInstall()); @@ -23,12 +19,18 @@ class MarkdownController { throw new Error(err); } - [, err] = await of(this.markdownService.updateMd(docPath)); + docs.forEach(async (doc) => { + if (!(await fs.pathExists(doc.path))) { + throw new Error(powerShellErrors.DOC_PATH_DOESNT_EXIST); + } - if (err) { - this.powerShellService.dispose(); - throw new Error(err); - } + [, err] = await of(this.markdownService.updateMd(doc)); + + if (err) { + this.powerShellService.dispose(); + throw new Error(err); + } + }); } } diff --git a/tools/office-cmdlet-updater/services/log.store.service.js b/tools/office-cmdlet-updater/services/log.store.service.js index ff37ffac19..43ae7ba7ec 100644 --- a/tools/office-cmdlet-updater/services/log.store.service.js +++ b/tools/office-cmdlet-updater/services/log.store.service.js @@ -40,8 +40,8 @@ class LogStoreService { fs.ensureFileSync(filePath); - const logs = this.getAllLogs() || ''; - const errors = this.getAllErrors() || ''; + const logs = this.getAllLogs().join('\n') || ''; + const errors = this.getAllErrors().join('\n') || ''; return fs.writeFile(filePath, logs + errors); } diff --git a/tools/office-cmdlet-updater/services/markdown.service.js b/tools/office-cmdlet-updater/services/markdown.service.js index 2ebb0a8553..d20c37235a 100644 --- a/tools/office-cmdlet-updater/services/markdown.service.js +++ b/tools/office-cmdlet-updater/services/markdown.service.js @@ -27,23 +27,32 @@ class MarkdownService { this.tempFolderPath = null; } - async updateMd(docPath) { - this.tempFolderPath = `${docPath}\\${shortId()}`; + async updateMd(doc) { + const { path } = doc; - await this.addMdFilesInQueue(docPath); + this.tempFolderPath = `${path}\\${shortId()}`; + + await this.addMdFilesInQueue(path); } async addMdFilesInQueue(folderPath) { const mdExt = '.md'; + const { ignoreFiles } = this.config.get('platyPS'); + const ignoreAbsolutePathsArr = ignoreFiles.map((f) => path.resolve(f)); + + const isFileIgnore = (fileName) => { + const absoluteFilePath = path.resolve(fileName); - const allFiles = await fs.readdir(folderPath); - const mdFiles = allFiles.filter((fileName) => fileName.endsWith(mdExt)); + return ignoreAbsolutePathsArr.includes(absoluteFilePath); + }; - mdFiles.forEach((fileName) => { - const absolutePath = path.resolve(`${folderPath}\\${fileName}`); + const mdFiles = (await fs.readdir(folderPath)) + .map((f) => path.resolve(folderPath, f)) + .filter((fn) => fn.endsWith(mdExt) && !isFileIgnore(fn)); + mdFiles.forEach((file) => { this.queue - .push(absolutePath) + .push(file) .on('failed', this.queueFailedHandler) .on('finish', this.queueFinishHandler); });