Skip to content

Commit

Permalink
fix(core): parse coverage path correctly on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
paambaati committed May 6, 2023
1 parent e03d453 commit 923001d
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as glob from '@actions/glob';
import {
downloadToFile,
getOptionalString,
parsePathAndFormat,
verifyChecksum,
verifySignature,
} from './utils';
Expand Down Expand Up @@ -144,18 +145,8 @@ async function getLocationLines(
.filter((pat) => pat)
.map((pat) => pat.trim());

const patternsAndFormats = coverageLocationPatternsLines.map((line) => {
let lineParts = line.split(':');
// On Windows, if the glob received an absolute path, the path will
// include the Drive letter and the path – for example, `C:\Users\gp\projects\cc\*.lcov:lcov`
// which leads to 2 colons. So we handle this special case.
if (PLATFORM === 'win32' && (line.match(/:/g) || []).length > 1) {
lineParts = [lineParts.slice(0, -1).join(':'), lineParts.slice(-1)[0]];
}
const format = lineParts.slice(-1)[0];
const pattern = lineParts.slice(0, -1)[0];
return { format, pattern };
});
const patternsAndFormats =
coverageLocationPatternsLines.map(parsePathAndFormat);

const pathsWithFormat = await Promise.all(
patternsAndFormats.map(async ({ format, pattern }) => {
Expand Down Expand Up @@ -267,7 +258,9 @@ export function run(
// Run format-coverage on each location.
const parts: Array<string> = [];
for (const i in coverageLocations) {
const [location, type] = coverageLocations[i].split(':');
const { format: type, pattern: location } = parsePathAndFormat(
coverageLocations[i]
);
if (!type) {
const err = new Error(`Invalid formatter type ${type}`);
debug(
Expand Down

0 comments on commit 923001d

Please sign in to comment.