Support path pattern to match test report files

This commit is contained in:
Michal Dorner 2021-01-16 21:07:12 +01:00
parent dfddea6f3f
commit 656ede0390
No known key found for this signature in database
GPG key ID: 9EEE04B48DA36786
2 changed files with 26 additions and 21 deletions

View file

@ -1,24 +1,10 @@
import * as fs from 'fs'
export function getFileContent(path: string): string {
if (!fs.existsSync(path)) {
throw new Error(`File '${path}' not found`)
}
if (!fs.lstatSync(path).isFile()) {
throw new Error(`'${path}' is not a file`)
}
return fs.readFileSync(path, {encoding: 'utf8'})
}
export function normalizeDirPath(path: string, trailingSeparator: boolean): string {
export function normalizeDirPath(path: string, addTrailingSlash: boolean): string {
if (!path) {
return path
}
path = normalizeFilePath(path)
if (trailingSeparator && !path.endsWith('/')) {
if (addTrailingSlash && !path.endsWith('/')) {
path += '/'
}
return path