Skip to content

Commit 0483f83

Browse files
committed
Merge branch 'craigbroadman-fix/handle-single-packages-in-cobertura-files'
2 parents 08f1c9c + f73b02f commit 0483f83

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/reports/cobertura/parser/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ import {
88
import {Cobertura, Package} from '../types'
99

1010
export default async function parse(cobertura: Cobertura): Promise<Coverage> {
11-
const fileList = cobertura.coverage.packages.package.map(
12-
({'@_name': name}) => {
13-
return name
14-
}
15-
)
11+
const packages = cobertura.coverage.packages.package
12+
const packageArray = Array.isArray(packages) ? packages : [packages]
1613

14+
const fileList = packageArray.map(({'@_name': name}) => {
15+
return name
16+
})
1717
const basePath = `${determineCommonBasePath(fileList)}`
1818
const r = new RegExp(`^${escapeRegExp(`${basePath}/`)}`)
1919

2020
return {
21-
files: cobertura.coverage.packages.package.reduce(
21+
files: packageArray.reduce(
2222
(previous, {'@_name': name, '@_line-rate': lineRate}: Package) => ({
2323
...previous,
2424
[createHash(name.replace(r, ''))]: {

0 commit comments

Comments
 (0)