Skip to content

Commit c8d14bc

Browse files
authored
Merge pull request #9 from matmanjs/fix_increase_fail
Fix increase fail
2 parents 99fa349 + 346550a commit c8d14bc

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "incremental-coverage",
3-
"version": "2.5.0",
3+
"version": "2.5.1",
44
"description": "Merge lcov.info and get incremental coverage and full coverage",
55
"main": "lib/index.js",
66
"bin": {

src/apis/process/full.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { CommitInfo, FullResult } from '../../types';
55
import { getActualGitRepoRoot } from "../../utils";
66

77
export class FullProcess<T extends keyof Mapper> extends BaseProcess<T> {
8+
private firstGitMessage: CommitInfo = {};
9+
810
constructor(lcovPath: string | string[], opts: BaseProcessOpts<T> = { stream: {} }) {
911
super();
1012

@@ -31,7 +33,7 @@ export class FullProcess<T extends keyof Mapper> extends BaseProcess<T> {
3133
createInfo = await this.getCreateInfo();
3234

3335
if (createInfo) {
34-
this.firstInfo = createInfo as CommitInfo;
36+
this.firstGitMessage = createInfo as CommitInfo;
3537
}
3638
}
3739

src/apis/process/increase.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class IncreaseProcess<T extends keyof Mapper> extends BaseProcess<T> {
6060
const createInfo = await this.getCreateInfo() as CommitInfo;
6161

6262
// 得到创建信息
63-
this.firstInfo = createInfo;
63+
this.firstGitMessage = createInfo;
6464

6565
// 得到增量合并结果
6666
await this.getLcov();
@@ -87,12 +87,13 @@ export class IncreaseProcess<T extends keyof Mapper> extends BaseProcess<T> {
8787
* 得到 lcov 结果
8888
*/
8989
private async getLcov() {
90+
// 解析获得 lcov.info 的信息,这里是全量覆盖率信息
9091
const res = await getLcovFile(this.lcovPath);
9192

9293
this.lcov = (
9394
await new IncreaseConcat({
9495
cwd: this.opts.cwd,
95-
hash: this.firstGitMessage.hash,
96+
hash: this.firstGitMessage?.hash,
9697
}).concat(...res)
9798
).getRes();
9899
}

src/apis/process/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ export abstract class BaseProcess<T extends keyof Mapper> {
3636
files: [],
3737
};
3838

39-
protected firstInfo: CommitInfo | undefined;
40-
4139
abstract async exec(): Promise<FullResult>;
4240

4341
/**

src/concat/increaseConcat.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export class IncreaseConcat implements Concat {
8585
};
8686

8787
Object.keys(this.res.detail).forEach((lcovItem) => {
88+
// 单个文件A的覆盖率数据,无法阅读的数据
8889
const info = this.res.detail[lcovItem];
8990
delete this.res.detail[lcovItem];
9091

@@ -113,7 +114,9 @@ export class IncreaseConcat implements Concat {
113114

114115
// 统计lcov中有记录的行
115116
const lcovLineArr: Array<number> = [];
117+
116118
const details = info.lines;
119+
117120
details.forEach((detail) => {
118121
const { hits } = detail;
119122
const { number } = detail;

0 commit comments

Comments
 (0)