forked from NickTomlin/protractor-flake
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse-options.js
More file actions
55 lines (48 loc) · 1.79 KB
/
Copy pathparse-options.js
File metadata and controls
55 lines (48 loc) · 1.79 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
48
49
50
51
52
53
54
55
import {resolve} from 'path'
import styles from 'chalk'
import * as fs from 'fs'
const DEFAULT_OPTIONS = {
nodeBin: 'node',
maxAttempts: 3,
protractorArgs: [],
// set color to one of the colors available at 'chalk' - https://github.com/chalk/ansi-styles#colors
// set false to disable coloring
color: 'magenta',
// the name of one of the included parsers
// a function to be used as a parser
// or the path to a node module that exports a parser
parser: 'standard',
// specify a different protractor config to apply after the first execution attempt
// either specify a config file, or cli args (ex. --capabilities.browser=chrome)
protractorRetryConfig: undefined
}
function parseOptions (providedOptions) {
let options = Object.assign({}, DEFAULT_OPTIONS, providedOptions)
// normalizing options.color to be a boolean or a color value
if (!(options.color in styles)) {
if (options.color === false || options.color === 'false') {
options.color = false
} else {
throw new Error('Invalid color option. Color must be one of the supported chalk colors: https://github.com/chalk/ansi-styles#colors')
}
}
if (options.protractorRetryConfig) {
let configPath = resolve(options.protractorRetryConfig)
try {
fs.lstatSync(configPath).isFile()
options.protractorRetryConfig = configPath
} catch (e) {
// do nothing, not a config path
}
}
if (options.protractorPath) {
options.protractorPath = resolve(options.protractorPath)
} else {
// '.../node_modules/protractor/lib/protractor.js'
let protractorMainPath = require.resolve('protractor')
// '.../node_modules/protractor/bin/protractor'
options.protractorPath = resolve(protractorMainPath, '../../bin/protractor')
}
return options
}
export default parseOptions