Skip to content
This repository was archived by the owner on Jul 23, 2025. It is now read-only.

Commit 54ac87c

Browse files
committed
fix(core): handle globs correctly in windows
1 parent de37362 commit 54ac87c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import {
1313
} from './utils';
1414
import type { ExecOptions } from '@actions/exec/lib/interfaces';
1515

16+
const PLATFORM = platform();
1617
// REFER: https://docs.codeclimate.com/docs/configuring-test-coverage#locations-of-pre-built-binaries
1718
/** Canonical download URL for the official CodeClimate reporter. */
1819
export const DOWNLOAD_URL = `https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${
19-
platform() === 'win32' ? 'windows' : platform()
20+
PLATFORM === 'win32' ? 'windows' : PLATFORM
2021
}-${arch() === 'arm64' ? 'arm64' : 'amd64'}`;
2122
/** Local file name of the CodeClimate reporter. */
2223
export const EXECUTABLE = './cc-reporter';
@@ -144,7 +145,13 @@ async function getLocationLines(
144145
.map((pat) => pat.trim());
145146

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

0 commit comments

Comments
 (0)