incremental-coverage
Advanced tools
Comparing version 2.6.0 to 2.7.0
@@ -9,8 +9,8 @@ import { BaseProcess, BaseProcessOpts, Mapper } from './index'; | ||
opts: IncreaseProcessOpts<T>; | ||
private firstGitMessage; | ||
private baseDiffCommitInfo; | ||
constructor(lcovPath: string | string[], opts?: IncreaseProcessOpts<T>); | ||
exec(): Promise<IncreaseResult>; | ||
private getLcov; | ||
private getLog; | ||
private getInfoByHash; | ||
private getCommitInfoByLogSince; | ||
private getCommitInfoByHash; | ||
} |
@@ -29,3 +29,2 @@ "use strict"; | ||
}; | ||
this.firstGitMessage = {}; | ||
if (typeof lcovPath === 'string') { | ||
@@ -48,6 +47,6 @@ this.lcovPath = [lcovPath]; | ||
if (this.opts.hash) { | ||
yield this.getInfoByHash(this.opts.hash); | ||
this.baseDiffCommitInfo = yield this.getCommitInfoByHash(this.opts.hash); | ||
} | ||
else { | ||
yield this.getLog(); | ||
if (!this.baseDiffCommitInfo) { | ||
this.baseDiffCommitInfo = yield this.getCommitInfoByLogSince(); | ||
} | ||
@@ -58,3 +57,2 @@ if (!this.opts.cwd) { | ||
const createInfo = yield this.getCreateInfo(); | ||
this.firstGitMessage = createInfo; | ||
yield this.getLcov(); | ||
@@ -65,3 +63,3 @@ this.format(); | ||
data: this.formatData, | ||
commit: this.firstGitMessage, | ||
commit: this.baseDiffCommitInfo, | ||
createInfo, | ||
@@ -72,3 +70,3 @@ }); | ||
data: this.formatData, | ||
commit: this.firstGitMessage, | ||
commit: this.baseDiffCommitInfo, | ||
createInfo, | ||
@@ -83,9 +81,10 @@ gitRepoInfo: this.getGitRepoInfo() | ||
const res = yield readLcov_1.getLcovFile(this.lcovPath); | ||
this.lcov = (yield new concat_1.IncreaseConcat({ | ||
const increaseConcat = yield new concat_1.IncreaseConcat({ | ||
cwd: this.opts.cwd, | ||
hash: (_a = this.firstGitMessage) === null || _a === void 0 ? void 0 : _a.hash, | ||
}).concat(...res)).getRes(); | ||
hash: (_a = this.baseDiffCommitInfo) === null || _a === void 0 ? void 0 : _a.hash, | ||
}).concat(...res); | ||
this.lcov = increaseConcat.getRes(); | ||
}); | ||
} | ||
getLog() { | ||
getCommitInfoByLogSince() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -95,13 +94,11 @@ const subDate = dayjs_1.default(this.opts.since).subtract(1, 'day').format('YYYY-MM-DD'); | ||
repo: this.opts.cwd, | ||
until: subDate, | ||
before: subDate, | ||
}).run(); | ||
[this.firstGitMessage] = res; | ||
return res[0]; | ||
}); | ||
} | ||
getInfoByHash(hash) { | ||
getCommitInfoByHash(hash) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const result = yield git_1.getGitRepoCommitInfoByHash(hash, this.opts.cwd); | ||
if (result) { | ||
this.firstGitMessage = result; | ||
} | ||
return result || undefined; | ||
}); | ||
@@ -108,0 +105,0 @@ } |
@@ -77,10 +77,28 @@ "use strict"; | ||
}; | ||
const diffLineArr = []; | ||
const diffInsertLineArr = []; | ||
const lineNumberCheckMap = {}; | ||
diffItem.hunks.forEach((hunk) => { | ||
hunk.changes.forEach((change) => { | ||
if (change.type === 'insert' && change.lineNumber) { | ||
diffLineArr.push(change.lineNumber); | ||
if (!change.lineNumber) { | ||
return; | ||
} | ||
const lineNumberCheckItem = lineNumberCheckMap[change.lineNumber] || {}; | ||
lineNumberCheckItem[change.type] = change.content; | ||
lineNumberCheckMap[change.lineNumber] = lineNumberCheckItem; | ||
if ((change.type === 'insert')) { | ||
diffInsertLineArr.push(change.lineNumber); | ||
} | ||
}); | ||
}); | ||
const diffLineArr = []; | ||
diffInsertLineArr.forEach((lineNumber) => { | ||
const lineNumberCheckItem = lineNumberCheckMap[lineNumber]; | ||
if (!lineNumberCheckItem) { | ||
return; | ||
} | ||
if (lineNumberCheckItem.insert && lineNumberCheckItem.delete && (lineNumberCheckItem.insert === lineNumberCheckItem.delete)) { | ||
return; | ||
} | ||
diffLineArr.push(lineNumber); | ||
}); | ||
const lcovLineHit = {}; | ||
@@ -87,0 +105,0 @@ const lcovLineArr = []; |
{ | ||
"name": "incremental-coverage", | ||
"version": "2.6.0", | ||
"version": "2.7.0", | ||
"description": "Merge lcov.info and get incremental coverage and full coverage", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62689
1372