This commit is contained in:
A. J. Kaptijn 2024-01-16 12:13:18 +01:00
parent 4da860cd59
commit 5473a04c5a
13 changed files with 22679 additions and 8953 deletions

View file

@ -2,6 +2,8 @@ import * as fs from 'fs'
import glob from 'fast-glob'
import {FileContent, InputProvider, ReportInput} from './input-provider.js'
import {listFiles} from '../utils/git.js'
import Zip from 'adm-zip'
import path from 'path'
export class LocalFileProvider implements InputProvider {
constructor(
@ -11,16 +13,19 @@ export class LocalFileProvider implements InputProvider {
async load(): Promise<ReportInput> {
const result: FileContent[] = []
const zip = new Zip()
for (const pat of this.pattern) {
const paths = await glob(pat, {dot: true})
for (const file of paths) {
const dir = path.dirname(file)
zip.addLocalFile(file, dir)
const content = await fs.promises.readFile(file, {encoding: 'utf8'})
result.push({file, content})
}
}
return {
artifactFilePaths: [],
trxZip: zip,
reports: {
[this.name]: result
}