-
Notifications
You must be signed in to change notification settings - Fork 19
/
options.ts
43 lines (34 loc) · 1.52 KB
/
options.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
import * as core from '@actions/core';
import { getCoverageModeFrom } from './FileCoverageMode';
import * as path from 'node:path';
import { getViteConfigPath } from './getViteConfigPath';
import { parseCoverageThresholds } from './parseCoverageThresholds';
async function readOptions() {
// Working directory can be used to modify all default/provided paths (for monorepos, etc)
const workingDirectory = core.getInput('working-directory');
const fileCoverageModeRaw = core.getInput('file-coverage-mode'); // all/changes/none
const fileCoverageMode = getCoverageModeFrom(fileCoverageModeRaw);
const jsonSummaryPath = path.resolve(workingDirectory, core.getInput('json-summary-path'));
const jsonFinalPath = path.resolve(workingDirectory, core.getInput('json-final-path'));
const jsonSummaryCompareInput = core.getInput('json-summary-compare-path');
let jsonSummaryComparePath;
if(jsonSummaryCompareInput) {
jsonSummaryComparePath = path.resolve(workingDirectory, jsonSummaryCompareInput);
}
const name = core.getInput('name');
// ViteConfig is optional, as it is only required for thresholds. If no vite config is provided, we will not include thresholds in the final report.
const viteConfigPath = await getViteConfigPath(workingDirectory, core.getInput("vite-config-path"));
const thresholds = viteConfigPath ? await parseCoverageThresholds(viteConfigPath) : {};
return {
fileCoverageMode,
jsonFinalPath,
jsonSummaryPath,
jsonSummaryComparePath,
name,
thresholds,
workingDirectory,
}
}
export {
readOptions
}