Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/helpers/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export async function getCoverageFiles(
}

export function fetchGitRoot(): string {
const currentWorkingDirectory = process.cwd()
const currentWorkingDirectory = process.cwd()
try {
const gitRoot = runExternalProgram('git', ['rev-parse', '--show-toplevel'])
return (gitRoot != "" ? gitRoot : currentWorkingDirectory)
Expand Down Expand Up @@ -320,7 +320,8 @@ export function getFilePath(projectRoot: string, filePath: string): string {
filePath.startsWith('./') ||
filePath.startsWith('/') ||
filePath.startsWith('.\\') ||
filePath.startsWith('.\\')
filePath.startsWith('.\\') ||
/^[A-Z]:\\\S*/.test(filePath) // This line is here to handle Windows drive letter absolute paths such as "C:\<path>"
) {
return filePath
}
Expand All @@ -347,7 +348,7 @@ export function getBlocklist(): string[] {
}

export function filterFilesAgainstBlockList(paths: string[], ignoreGlobs: string[]): string[] {
return micromatch.not(paths, ignoreGlobs, {windows: true})
return micromatch.not(paths, ignoreGlobs, { windows: true })
}

export function cleanCoverageFilePaths(projectRoot: string, paths: string[]): string[] {
Expand Down
9 changes: 7 additions & 2 deletions test/helpers/files.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('File Helpers', () => {
const cwd = td.replace(process, 'cwd')
td.replace(childProcess, 'spawnSync')
td.when(cwd()).thenReturn({ stdout: 'fish' })
expect(fileHelpers.fetchGitRoot()).toEqual({stdout: 'fish'})
expect(fileHelpers.fetchGitRoot()).toEqual({ stdout: 'fish' })
})

it('can get a file listing', async () => {
Expand All @@ -52,7 +52,7 @@ describe('File Helpers', () => {
}
})
expect(
await fileHelpers.getFileListing('.', { flags: '', verbose: 'true', slug: '',upstream: '' }),
await fileHelpers.getFileListing('.', { flags: '', verbose: 'true', slug: '', upstream: '' }),
).toBe(files.join('\n'))
})

Expand Down Expand Up @@ -279,6 +279,11 @@ describe('File Helpers', () => {
'/usr/coverage.xml',
)
})
it('should return path when file path starts with Windows letter drive', () => {
expect(fileHelpers.getFilePath('.', 'C:\Users\circleci\project\coverage\cobertura-coverage.xml')).toEqual(
'C:\Users\circleci\project\coverage\cobertura-coverage.xml',
)
})
})
})

Expand Down