mirror of
https://github.com/dorny/test-reporter.git
synced 2026-02-04 05:27:55 +01:00
Add support for loading test results from artifacts
This commit is contained in:
parent
71f2f95ef0
commit
3510d9ac27
19 changed files with 11665 additions and 338 deletions
39
src/utils/path-utils.ts
Normal file
39
src/utils/path-utils.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
export function normalizeDirPath(path: string, addTrailingSlash: boolean): string {
|
||||
if (!path) {
|
||||
return path
|
||||
}
|
||||
|
||||
path = normalizeFilePath(path)
|
||||
if (addTrailingSlash && !path.endsWith('/')) {
|
||||
path += '/'
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
export function normalizeFilePath(path: string): string {
|
||||
if (!path) {
|
||||
return path
|
||||
}
|
||||
|
||||
return path.trim().replace(/\\/g, '/')
|
||||
}
|
||||
|
||||
export function getBasePath(path: string, trackedFiles: string[]): string | undefined {
|
||||
if (trackedFiles.includes(path)) {
|
||||
return ''
|
||||
}
|
||||
|
||||
let max = ''
|
||||
for (const file of trackedFiles) {
|
||||
if (path.endsWith(file) && file.length > max.length) {
|
||||
max = file
|
||||
}
|
||||
}
|
||||
|
||||
if (max === '') {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const base = path.substr(0, path.length - max.length)
|
||||
return base
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue