From 77bff24534188d50488e87ba905fa88bb24f20fd Mon Sep 17 00:00:00 2001 From: Misha Kav Date: Fri, 21 Jan 2022 18:57:03 +0200 Subject: [PATCH] fix reportOnlyChangedFiles --- dist/index.js | 23 ++++++++++++++--------- src/cli.js | 10 +++++++++- src/parse.js | 23 ++++++++++++++--------- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/dist/index.js b/dist/index.js index 03c980c..cffc567 100644 --- a/dist/index.js +++ b/dist/index.js @@ -13256,19 +13256,24 @@ const toTable = (data, options) => { const rows = Object.keys(folders) .sort() + .filter((folderPath) => { + if (!options.reportOnlyChangedFiles) { + return true; + } + + const allFilesInFolder = Object.values(folders[folderPath]).map( + (f) => f.name + ); + + return allFilesInFolder.every((f) => + options.changedFiles.all.some((c) => c.includes(f)) + ); + }) .reduce( (acc, key) => [ ...acc, toFolderTd(key, options), - ...folders[key] - .filter((file) => { - console.log(file); - return ( - options.reportOnlyChangedFiles && - !options.changedFiles.all.some((f) => f.includes(file)) - ); - }) - .map((file) => toRow(file, key !== '', options)), + ...folders[key].map((file) => toRow(file, key !== '', options)), ], [] ); diff --git a/src/cli.js b/src/cli.js index b2e5ee4..aaf65cb 100644 --- a/src/cli.js +++ b/src/cli.js @@ -59,9 +59,17 @@ const main = async () => { hideBadge: false, hideReport: false, createNewComment: false, + reportOnlyChangedFiles: true, hideComment: false, xmlTitle: '', - multipleFiles, + // multipleFiles, + changedFiles: { + all: [ + 'functions/example_completed/example_completed.py', + 'functions/example_manager/example_manager.py', + 'functions/example_manager/example_static.py', + ], + }, }; if (options.multipleFiles && options.multipleFiles.length) { diff --git a/src/parse.js b/src/parse.js index 16a1d9c..2c47447 100644 --- a/src/parse.js +++ b/src/parse.js @@ -221,19 +221,24 @@ const toTable = (data, options) => { const rows = Object.keys(folders) .sort() + .filter((folderPath) => { + if (!options.reportOnlyChangedFiles) { + return true; + } + + const allFilesInFolder = Object.values(folders[folderPath]).map( + (f) => f.name + ); + + return allFilesInFolder.every((f) => + options.changedFiles.all.some((c) => c.includes(f)) + ); + }) .reduce( (acc, key) => [ ...acc, toFolderTd(key, options), - ...folders[key] - .filter((file) => { - console.log(file); - return ( - options.reportOnlyChangedFiles && - !options.changedFiles.all.some((f) => f.includes(file)) - ); - }) - .map((file) => toRow(file, key !== '', options)), + ...folders[key].map((file) => toRow(file, key !== '', options)), ], [] );