-
-
Notifications
You must be signed in to change notification settings - Fork 175
/
Copy pathparse-options.js
64 lines (60 loc) · 2.39 KB
/
parse-options.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
52
53
54
55
56
57
58
59
60
61
62
63
64
const path = require('path');
const minimist = require('minimist');
const ciInfo = require('ci-info');
const defaults = require('./default-options');
function parseOptions(args, config) {
const argv = minimist(args, {
boolean: [
'requireReference',
'chromeEnableAnimations',
'verboseRenderer',
'dockerWithSudo',
'chromeDockerWithoutSeccomp',
],
});
const $ = (key) => argv[key] || config[key] || defaults[key];
return {
outputDir: path.resolve($('output')),
referenceDir: path.resolve($('reference')),
differenceDir: path.resolve($('difference')),
fileNameFormatter: config.fileNameFormatter,
reactUri:
$('reactUri') || `http://${$('host')}:${argv.port || $('reactPort')}`,
reactNativeUri: `ws://${$('host')}:${argv.port || $('reactNativePort')}`,
dockerNet: $('dockerNet'),
chromeAwsLambdaFunctionName: $('chromeAwsLambdaFunctionName'),
chromeAwsLambdaRetries: parseInt($('chromeAwsLambdaRetries'), 10),
chromeAwsLambdaBatchSize: parseInt($('chromeAwsLambdaBatchSize'), 10),
chromeAwsLambdaBatchConcurrency: parseInt(
$('chromeAwsLambdaBatchConcurrency'),
10
),
chromeConcurrency: parseInt($('chromeConcurrency'), 10),
chromeDockerImage: $('chromeDockerImage'),
chromeEnableAnimations: $('chromeEnableAnimations'),
chromeFlags: $('chromeFlags').split(' '),
chromeLoadTimeout: parseInt($('chromeLoadTimeout'), 10),
chromeRetries: parseInt($('chromeRetries'), 10),
chromeSelector: $('chromeSelector'),
chromeTolerance: parseFloat($('chromeTolerance'), 10),
chromeEmulatedMedia: $('chromeEmulatedMedia'),
skipStoriesPattern: $('skipStories'),
storiesFilter: $('storiesFilter'),
diffingEngine: $('diffingEngine') || 'pixelmatch',
includeReferenceOnDiff: $('includeReferenceOnDiff'),
fetchFailIgnore: $('fetchFailIgnore'),
'looks-same': $('looks-same'),
gm: $('gm'),
pixelmatch: $('pixelmatch'),
verboseRenderer: $('verboseRenderer'),
silent: $('silent'),
requireReference: $('requireReference') || ciInfo.isCI,
updateReference: argv._[0] === 'update',
targetFilter: argv.targetFilter,
configurationFilter: argv.configurationFilter || argv._[1],
dockerWithSudo: $('dockerWithSudo'),
chromeDockerUseCopy: $('chromeDockerUseCopy'),
chromeDockerWithoutSeccomp: $('chromeDockerWithoutSeccomp'),
};
}
module.exports = parseOptions;