-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathsettings.ts
More file actions
47 lines (43 loc) · 1.19 KB
/
settings.ts
File metadata and controls
47 lines (43 loc) · 1.19 KB
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
import { SchemaValidationError, validate } from '@code-pushup/models';
import type { ConfigPatterns, Settings } from './models.js';
import { configPatternsSchema } from './schemas.js';
export const DEFAULT_SETTINGS: Settings = {
monorepo: false,
parallel: false,
projects: null,
task: 'code-pushup',
bin: 'npx --no-install code-pushup',
config: null,
directory: process.cwd(),
silent: false,
debug: false,
detectNewIssues: true,
logger: console,
nxProjectsFilter: '--with-target={task}',
skipComment: false,
configPatterns: null,
searchCommits: false,
};
export const MIN_SEARCH_COMMITS = 1;
export const MAX_SEARCH_COMMITS = 100;
export function parseConfigPatternsFromString(
value: string,
): ConfigPatterns | null {
if (!value) {
return null;
}
try {
const json = JSON.parse(value);
return validate(configPatternsSchema, json);
} catch (error) {
if (error instanceof SyntaxError) {
throw new TypeError(
`Invalid JSON value for configPatterns input - ${error.message}`,
);
}
if (error instanceof SchemaValidationError) {
throw new TypeError(`Invalid shape of configPatterns input:\n${error}`);
}
throw error;
}
}