mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-15 22:07:09 +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
25
src/input-providers/local-file-provider.ts
Normal file
25
src/input-providers/local-file-provider.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import * as fs from 'fs'
|
||||
import glob from 'fast-glob'
|
||||
import {FileContent, InputProvider, ReportInput} from './input-provider'
|
||||
import {listFiles} from '../utils/git'
|
||||
|
||||
export class LocalFileProvider implements InputProvider {
|
||||
constructor(readonly name: string, readonly pattern: string[]) {}
|
||||
|
||||
async load(): Promise<ReportInput> {
|
||||
const result: FileContent[] = []
|
||||
for (const pat of this.pattern) {
|
||||
const paths = await glob(pat, {dot: true})
|
||||
for (const file of paths) {
|
||||
const content = await fs.promises.readFile(file, {encoding: 'utf8'})
|
||||
result.push({file, content})
|
||||
}
|
||||
}
|
||||
|
||||
return {[this.name]: result}
|
||||
}
|
||||
|
||||
async listTrackedFiles(): Promise<string[]> {
|
||||
return listFiles()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue