-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.js
51 lines (46 loc) · 1.62 KB
/
config.js
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
'use strict';
const {root, section, option, map} = require('gemini-configparser');
const {assertBoolean, assertString, assertRequestedType, assertPositiveInteger} = require('./asserts');
const ENV_PREFIX = 'testplane_retry_command_';
const CLI_PREFIX = '--testplane-retry-command-';
const getParser = () => {
return root(section({
enabled: option({
defaultValue: true,
parseEnv: JSON.parse,
parseCli: JSON.parse,
validate: assertBoolean('enabled')
}),
rules: map(
section({
condition: option({
validate: assertString('condition')
}),
browsers: option({
defaultValue: /.*/,
validate: assertRequestedType(
'browsers',
['String', 'RegExp', 'Array']
)
}),
retryOnlyFirst: option({
defaultValue: false,
validate: assertBoolean('retryOnlyFirst')
}),
retryCount: option({
defaultValue: 2,
validate: assertPositiveInteger('retryCount')
}),
retryInterval: option({
defaultValue: 100,
validate: assertPositiveInteger('retryInterval')
})
})
)
}), {envPrefix: ENV_PREFIX, cliPrefix: CLI_PREFIX});
};
module.exports = (options) => {
const env = process.env;
const argv = process.argv;
return getParser()({options, env, argv});
};