Skip to content

Commit

Permalink
refactor: normalize path to unix when found
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarvin8 committed Jan 9, 2025
1 parent d96bd88 commit 34bb533
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/handlers/cloverCoverageHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

import { CloverCoverageObject, CloverFile, CoverageHandler } from '../helpers/types.js';
import { normalizePathToUnix } from '../helpers/normalizePathToUnix.js';

export class CloverCoverageHandler implements CoverageHandler {
private readonly coverageObj: CloverCoverageObject;
Expand Down Expand Up @@ -45,7 +44,7 @@ export class CloverCoverageHandler implements CoverageHandler {
): void {
const fileObj: CloverFile = {
'@name': fileName,
'@path': normalizePathToUnix(filePath),
'@path': filePath,
metrics: {
'@statements': uncoveredLines.length + coveredLines.length,
'@coveredstatements': coveredLines.length,
Expand Down
3 changes: 1 addition & 2 deletions src/handlers/coberturaCoverageHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

import { CoberturaCoverageObject, CoberturaPackage, CoberturaClass, CoverageHandler } from '../helpers/types.js';
import { normalizePathToUnix } from '../helpers/normalizePathToUnix.js';

export class CoberturaCoverageHandler implements CoverageHandler {
private readonly coverageObj: CoberturaCoverageObject;
Expand Down Expand Up @@ -41,7 +40,7 @@ export class CoberturaCoverageHandler implements CoverageHandler {
): void {
const classObj: CoberturaClass = {
'@name': fileName,
'@filename': normalizePathToUnix(filePath),
'@filename': filePath,
'@line-rate': '0',
'@branch-rate': '1',
methods: {},
Expand Down
3 changes: 1 addition & 2 deletions src/handlers/lcovCoverageHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

import { CoverageHandler, LcovCoverageObject, LcovFile } from '../helpers/types.js';
import { normalizePathToUnix } from '../helpers/normalizePathToUnix.js';

export class LcovCoverageHandler implements CoverageHandler {
private readonly coverageObj: LcovCoverageObject;
Expand All @@ -18,7 +17,7 @@ export class LcovCoverageHandler implements CoverageHandler {
coveredLines: number[],
): void {
const lcovFile: LcovFile = {
sourceFile: normalizePathToUnix(filePath),
sourceFile: filePath,
lines: [],
totalLines: uncoveredLines.length + coveredLines.length,
coveredLines: coveredLines.length,
Expand Down
3 changes: 1 addition & 2 deletions src/handlers/sonarCoverageHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

import { SonarCoverageObject, SonarClass, CoverageHandler } from '../helpers/types.js';
import { normalizePathToUnix } from '../helpers/normalizePathToUnix.js';

export class SonarCoverageHandler implements CoverageHandler {
private readonly coverageObj: SonarCoverageObject;
Expand All @@ -16,7 +15,7 @@ export class SonarCoverageHandler implements CoverageHandler {
lines: Record<string, number>,
): void {
const fileObj: SonarClass = {
'@path': normalizePathToUnix(filePath),
'@path': filePath,
lineToCover: [],
};
for (const lineNumberString in lines) {
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/findFilePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { readdir, stat } from 'node:fs/promises';
import { join, relative } from 'node:path';
import { normalizePathToUnix } from './normalizePathToUnix.js';

export async function findFilePath(
fileName: string,
Expand All @@ -13,6 +14,7 @@ export async function findFilePath(
for (const directory of packageDirectories) {
relativeFilePath = await findFilePathinDirectory(fileName, directory, repoRoot);
if (relativeFilePath !== undefined) {
relativeFilePath = normalizePathToUnix(relativeFilePath)
break;
}
}
Expand Down

0 comments on commit 34bb533

Please sign in to comment.