Skip to content

Commit

Permalink
parse proxy settings from flags and config file
Browse files Browse the repository at this point in the history
  • Loading branch information
corevo committed Nov 28, 2018
1 parent 882c811 commit 94bc53e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/selenium-side-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"glob": "^7.1.2",
"global-npm": "^0.3.0",
"jest": "23.4.2",
"jest-environment-selenium": "2.0.0",
"jest-environment-selenium": "2.1.0",
"js-beautify": "^1.7.5",
"js-yaml": "^3.10.0",
"rimraf": "^2.6.2",
Expand Down
50 changes: 40 additions & 10 deletions packages/selenium-side-runner/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import rimraf from 'rimraf'
import { js_beautify as beautify } from 'js-beautify'
import Selianize, { getUtilsFile } from 'selianize'
import Capabilities from './capabilities'
import ParseProxy from './proxy'
import Config from './config'
import Satisfies from './versioner'
import metadata from '../package.json'
Expand All @@ -53,6 +54,14 @@ program
'--timeout [number | undefined]',
`The maximimum amount of time, in milliseconds, to spend attempting to locate an element. (default: ${DEFAULT_TIMEOUT})`
)
.option(
'--proxy-type [type]',
'Type of proxy to use (one of: direct, manual, pac, socks, system)'
)
.option(
'--proxy-options [list]',
'Proxy options to pass, for use with manual, pac and socks proxies'
)
.option(
'--configuration-file [filepath]',
'Use specified YAML file for configuration. (default: .side.yml)'
Expand All @@ -63,7 +72,7 @@ program
)
.option(
'--force',
"Forciblly run the project, regardless of project's version"
"Forcibly run the project, regardless of project's version"
)
.option('--debug', 'Print debug logs')

Expand Down Expand Up @@ -103,16 +112,12 @@ const configuration = {
path: path.join(__dirname, '../../'),
}

const configurationFilePath = program.configurationFile || '.side.yml'
const confPath = program.configurationFile || '.side.yml'
const configurationFilePath = path.isAbsolute(confPath)
? confPath
: path.join(process.cwd(), confPath)
try {
Object.assign(
configuration,
Config.load(
path.isAbsolute(configurationFilePath)
? configurationFilePath
: path.join(process.cwd(), configurationFilePath)
)
)
Object.assign(configuration, Config.load(configurationFilePath))
} catch (e) {
winston.debug('Could not load ' + configurationFilePath)
}
Expand Down Expand Up @@ -150,6 +155,31 @@ if (program.params) {
}
}

if (program.proxyType) {
try {
let opts = program.proxyOptions
if (program.proxyType === 'manual' || program.proxyType === 'socks') {
opts = Capabilities.parseString(opts)
}
const proxy = ParseProxy(program.proxyType, opts)
Object.assign(configuration, proxy)
} catch (e) {
winston.error(e.message)
process.exit(1)
}
} else if (configuration.proxyType) {
try {
const proxy = ParseProxy(
configuration.proxyType,
configuration.proxyOptions
)
Object.assign(configuration, proxy)
} catch (e) {
winston.error(e.message)
process.exit(1)
}
}

configuration.baseUrl = program.baseUrl
? program.baseUrl
: configuration.baseUrl
Expand Down
8 changes: 4 additions & 4 deletions packages/selenium-side-runner/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2931,10 +2931,10 @@ jest-environment-node@^23.4.0:
jest-mock "^23.2.0"
jest-util "^23.4.0"

jest-environment-selenium@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/jest-environment-selenium/-/jest-environment-selenium-2.0.0.tgz#e3e7222750fbdb4b5d29e41a14fa382d30c2b778"
integrity sha512-djAASYYULpx2UFNrjqaOZiM8Boxoo9uhKBbjjjSIiUV3W3plGF73hFeC8gh97/HvztzYPTF63gGGp0uQnqZ3SQ==
jest-environment-selenium@2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/jest-environment-selenium/-/jest-environment-selenium-2.1.0.tgz#f1bf4584b6d80fc2dbe48d147f79b8fca7154ca8"
integrity sha512-1P6y6326Py+b51JPGjaAqValZpK3qpP43sFpCjusDcz5iLOpeKzxzM33u9ErU3uBtL2ovElxe4Bkj2tiZ8km3Q==

jest-get-type@^22.1.0:
version "22.4.3"
Expand Down

0 comments on commit 94bc53e

Please sign in to comment.