@vitest/coverage-istanbul
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -171,2 +171,3 @@ import { promises, existsSync, writeFileSync } from 'node:fs'; | ||
sourceMap.sources = sourceMap.sources.map(removeQueryParameters); | ||
sourceCode = sourceCode.replaceAll("_ts_decorate", "/* istanbul ignore next */_ts_decorate"); | ||
const code = this.instrumenter.instrumentSync(sourceCode, id, sourceMap); | ||
@@ -214,3 +215,3 @@ const map = this.instrumenter.lastSourceMap(); | ||
const coverageMapByTransformMode = libCoverage.createCoverageMap({}); | ||
for (const chunk of toSlices(filenames, this.options.processingConcurrency)) { | ||
for (const chunk of this.toSlices(filenames, this.options.processingConcurrency)) { | ||
if (debug.enabled) { | ||
@@ -240,3 +241,3 @@ index += chunk.length; | ||
}); | ||
if (hasTerminalReporter(this.options.reporter)) | ||
if (this.hasTerminalReporter(this.options.reporter)) | ||
this.ctx.logger.log(c.blue(" % ") + c.dim("Coverage report from ") + c.yellow(this.name)); | ||
@@ -268,6 +269,4 @@ for (const reporter of this.options.reporter) { | ||
perFile: this.options.thresholds.perFile, | ||
configurationFile: { | ||
write: () => writeFileSync(configFilePath, configModule.generate().code, "utf-8"), | ||
read: () => resolveConfig(configModule) | ||
} | ||
configurationFile: configModule, | ||
onUpdate: () => writeFileSync(configFilePath, configModule.generate().code, "utf-8") | ||
}); | ||
@@ -323,34 +322,3 @@ } | ||
} | ||
function hasTerminalReporter(reporters) { | ||
return reporters.some(([reporter]) => reporter === "text" || reporter === "text-summary" || reporter === "text-lcov" || reporter === "teamcity"); | ||
} | ||
function toSlices(array, size) { | ||
return array.reduce((chunks, item) => { | ||
const index = Math.max(0, chunks.length - 1); | ||
const lastChunk = chunks[index] || []; | ||
chunks[index] = lastChunk; | ||
if (lastChunk.length >= size) | ||
chunks.push([item]); | ||
else | ||
lastChunk.push(item); | ||
return chunks; | ||
}, []); | ||
} | ||
function resolveConfig(configModule) { | ||
const mod = configModule.exports.default; | ||
try { | ||
if (mod.$type === "object") | ||
return mod; | ||
if (mod.$type === "function-call") { | ||
if (mod.$args[0].$type === "object") | ||
return mod.$args[0]; | ||
if (mod.$args[0].$type === "arrow-function-expression" && mod.$args[0].$body.$type === "object") | ||
return mod.$args[0].$body; | ||
} | ||
} catch (error) { | ||
throw new Error(error instanceof Error ? error.message : String(error)); | ||
} | ||
throw new Error("Failed to update coverage thresholds. Configuration file is too complex."); | ||
} | ||
export { IstanbulCoverageProvider }; |
{ | ||
"name": "@vitest/coverage-istanbul", | ||
"type": "module", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Istanbul coverage provider for Vitest", | ||
@@ -40,3 +40,3 @@ "author": "Anthony Fu <anthonyfu117@hotmail.com>", | ||
"peerDependencies": { | ||
"vitest": "1.3.0" | ||
"vitest": "1.3.1" | ||
}, | ||
@@ -62,3 +62,3 @@ "dependencies": { | ||
"pathe": "^1.1.1", | ||
"vitest": "1.3.0" | ||
"vitest": "1.3.1" | ||
}, | ||
@@ -65,0 +65,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
18403
389