diff options
| author | Kevin J Hoerr <kjhoerr@protonmail.com> | 2021-09-12 15:36:49 -0400 |
|---|---|---|
| committer | Kevin J Hoerr <kjhoerr@protonmail.com> | 2021-09-12 15:36:49 -0400 |
| commit | 77575aab559f058d886a691eefe262cf0f306710 (patch) | |
| tree | 04a42450b1434905d10840525eacf5c05a18586f /src/formats.ts | |
| parent | c3ce0680a9828d9bd3fc18f0c0f6ee87fa40868e (diff) | |
| download | ao-coverage-77575aab559f058d886a691eefe262cf0f306710.tar.gz ao-coverage-77575aab559f058d886a691eefe262cf0f306710.tar.bz2 ao-coverage-77575aab559f058d886a691eefe262cf0f306710.zip | |
Refactor coverage upload for ease of new formats
Diffstat (limited to 'src/formats.ts')
| -rw-r--r-- | src/formats.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/formats.ts b/src/formats.ts index 63d5f60..11113f0 100644 --- a/src/formats.ts +++ b/src/formats.ts @@ -1,10 +1,11 @@ +import { JSDOM } from "jsdom"; import { InvalidReportDocumentError } from "./errors"; type CoverageResult = number | InvalidReportDocumentError; export interface Format { // returns the coverage value as %: Number(90.0), Number(100.0), Number(89.5) - parseCoverage: (file: Document) => CoverageResult; + parseCoverage: (contents: string) => CoverageResult; matchColor: (coverage: number, style: GradientStyle) => string; fileName: string; } @@ -45,7 +46,8 @@ export const defaultColorMatches = ( const FormatsObj: FormatObj = { formats: { tarpaulin: { - parseCoverage: (file: Document): CoverageResult => { + parseCoverage: (contents: string): CoverageResult => { + const file = new JSDOM(contents).window.document; const scripts = file.getElementsByTagName("script"); if (scripts.length === 0) { return new InvalidReportDocumentError(); |
