Skip to content

Commit e4c3d57

Browse files
Fix error (#4)
* change to master branch * change to master branch * bug fix
1 parent de654db commit e4c3d57

File tree

3 files changed

+52
-8
lines changed

3 files changed

+52
-8
lines changed

dist/main.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5923,6 +5923,7 @@ function commentForMonorepo(
59235923
const baseLcov = lcovBaseArrayForMonorepo.find(
59245924
el => el.packageName === lcovObj.packageName,
59255925
);
5926+
59265927
const pbefore = baseLcov ? percentage(baseLcov) : 0;
59275928
const pafter = baseLcov ? percentage(lcovObj.lcov) : 0;
59285929
const pdiff = pafter - pbefore;
@@ -6094,15 +6095,36 @@ var github_1$1 = github$2.upsertComment;
60946095
* @function getLcovFiles
60956096
* @param {string} dir Dir path string.
60966097
* @return {string[{<package_name>: <path_to_lcov_file>}]} Array with lcove file names with package names as key.
6097-
* @param {string} lcovFileName path string for lcov file for PR or base lcov file.
60986098
*/
6099-
const getLcovFiles = (dir, filelist = [], lcovFileName = "lcov.info") => {
6099+
const getLcovFiles = (dir, filelist = []) => {
61006100
fs__default.readdirSync(dir).forEach(file => {
61016101
filelist = fs__default.statSync(path.join(dir, file)).isDirectory()
61026102
? getLcovFiles(path.join(dir, file), filelist)
61036103
: filelist
61046104
.filter(file => {
6105-
return file.path.includes(lcovFileName);
6105+
return file.path.includes("lcov.info");
6106+
})
6107+
.concat({
6108+
name: dir.split("/")[1],
6109+
path: path.join(dir, file),
6110+
});
6111+
});
6112+
return filelist;
6113+
};
6114+
6115+
/**
6116+
* Find all files inside a dir, recursively for base branch.
6117+
* @function getLcovBaseFiles
6118+
* @param {string} dir Dir path string.
6119+
* @return {string[{<package_name>: <path_to_lcov_file>}]} Array with lcove file names with package names as key.
6120+
*/
6121+
const getLcovBaseFiles = (dir, filelist = []) => {
6122+
fs__default.readdirSync(dir).forEach(file => {
6123+
filelist = fs__default.statSync(path.join(dir, file)).isDirectory()
6124+
? getLcovBaseFiles(path.join(dir, file), filelist)
6125+
: filelist
6126+
.filter(file => {
6127+
return file.path.includes("lcov-base.info");
61066128
})
61076129
.concat({
61086130
name: dir.split("/")[1],
@@ -6138,7 +6160,7 @@ async function main() {
61386160

61396161
let lcovArray = monorepoBasePath ? getLcovFiles(monorepoBasePath) : [];
61406162
let lcovBaseArray = monorepoBasePath
6141-
? getLcovFiles(monorepoBasePath, [], "lcov-base.info")
6163+
? getLcovBaseFiles(monorepoBasePath)
61426164
: [];
61436165

61446166
const lcovArrayForMonorepo = [];

src/comment.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export function commentForMonorepo(
1717
const baseLcov = lcovBaseArrayForMonorepo.find(
1818
el => el.packageName === lcovObj.packageName,
1919
);
20+
2021
const pbefore = baseLcov ? percentage(baseLcov) : 0;
2122
const pafter = baseLcov ? percentage(lcovObj.lcov) : 0;
2223
const pdiff = pafter - pbefore;

src/index.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,36 @@ import { upsertComment } from "./github";
1111
* @function getLcovFiles
1212
* @param {string} dir Dir path string.
1313
* @return {string[{<package_name>: <path_to_lcov_file>}]} Array with lcove file names with package names as key.
14-
* @param {string} lcovFileName path string for lcov file for PR or base lcov file.
1514
*/
16-
const getLcovFiles = (dir, filelist = [], lcovFileName = "lcov.info") => {
15+
const getLcovFiles = (dir, filelist = []) => {
1716
fs.readdirSync(dir).forEach(file => {
1817
filelist = fs.statSync(path.join(dir, file)).isDirectory()
1918
? getLcovFiles(path.join(dir, file), filelist)
2019
: filelist
2120
.filter(file => {
22-
return file.path.includes(lcovFileName);
21+
return file.path.includes("lcov.info");
22+
})
23+
.concat({
24+
name: dir.split("/")[1],
25+
path: path.join(dir, file),
26+
});
27+
});
28+
return filelist;
29+
};
30+
31+
/**
32+
* Find all files inside a dir, recursively for base branch.
33+
* @function getLcovBaseFiles
34+
* @param {string} dir Dir path string.
35+
* @return {string[{<package_name>: <path_to_lcov_file>}]} Array with lcove file names with package names as key.
36+
*/
37+
const getLcovBaseFiles = (dir, filelist = []) => {
38+
fs.readdirSync(dir).forEach(file => {
39+
filelist = fs.statSync(path.join(dir, file)).isDirectory()
40+
? getLcovBaseFiles(path.join(dir, file), filelist)
41+
: filelist
42+
.filter(file => {
43+
return file.path.includes("lcov-base.info");
2344
})
2445
.concat({
2546
name: dir.split("/")[1],
@@ -55,7 +76,7 @@ async function main() {
5576

5677
let lcovArray = monorepoBasePath ? getLcovFiles(monorepoBasePath) : [];
5778
let lcovBaseArray = monorepoBasePath
58-
? getLcovFiles(monorepoBasePath, [], "lcov-base.info")
79+
? getLcovBaseFiles(monorepoBasePath)
5980
: [];
6081

6182
const lcovArrayForMonorepo = [];

0 commit comments

Comments
 (0)