-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathconfig.model.ts
62 lines (57 loc) · 1.7 KB
/
config.model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
export type ReportFileSet = "created" | "modified" | "createdOrModified" | "all"
export type ReportMode = "fail" | "warn" | "message"
export type SortMethod =
| "alphabetically"
| "least-coverage"
| "most-coverage"
| "largest-file-size"
| "smallest-file-size"
| "uncovered-lines"
export type SourceType = "json-summary" | "lcov"
export interface SourcePathExplicit {
path: string
type: SourceType
}
export type SourcePath = string | SourcePathExplicit
export interface CoverageThreshold {
statements: number
branches: number
functions: number
lines: number
}
export interface Config {
customSuccessMessage?: string
customFailureMessage?: string
numberOfEntries: number
entrySortMethod: SortMethod
coveragePath?: SourcePath
coveragePaths: SourcePath[]
reportFileSet: ReportFileSet
threshold: CoverageThreshold
reportMode: ReportMode
}
/**
* Completes a partial configuration with default values.
* @param config The configuration to complete
* @returns A complete configuration
*/
export function makeCompleteConfiguration(config?: Partial<Config>): Config {
const defaults: Config = {
coveragePaths: [],
reportFileSet: "all",
reportMode: "message",
entrySortMethod: "alphabetically",
numberOfEntries: 10,
threshold: {
statements: 100,
branches: 100,
functions: 100,
lines: 100,
},
}
const combined = config ? { ...defaults, ...config } : defaults
const coveragePath = combined.coveragePath ? combined.coveragePath : "./coverage/coverage-summary.json"
const coveragePaths = combined.coveragePaths.length === 0 ? [coveragePath] : combined.coveragePaths
delete combined.coveragePath
return { ...combined, coveragePaths }
}