-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.js
42 lines (37 loc) · 1.28 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
'use strict';
const {root, section, option} = require('gemini-configparser');
const ENV_PREFIX = 'hermione_hide_scrollbars_';
const CLI_PREFIX = '--hide-scrollbars-';
const getParser = () => {
return root(section({
enabled: option({
defaultValue: true,
parseEnv: JSON.parse,
parseCli: JSON.parse,
validate: (value) => {
if (typeof value !== 'boolean') {
throw new Error(`'enabled' must be boolean but got '${value}'`);
}
}
}),
browsers: option({
defaultValue: [],
validate: (value) => {
if (!(value instanceof Array) || value.some((v) => typeof v !== 'string')) {
throw new Error(`'browsers' must be an array of strings`);
}
}
}),
browserWSEndpoint: option({
validate: (value) => {
if (typeof value !== 'function') {
throw new Error(`'browserWSEndpoint' must be function, but got '${value}'`);
}
}
})
}), {envPrefix: ENV_PREFIX, cliPrefix: CLI_PREFIX});
};
module.exports = (options) => {
const {env, argv} = process;
return getParser()({options, env, argv});
};