Skip to content

Commit

Permalink
log driver start
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Jul 25, 2023
1 parent 65140cb commit de01d35
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os from 'node:os'
import logger from '@wdio/logger'

export const MOZ_CENTRAL_CARGO_TOML = 'https://hg.mozilla.org/mozilla-central/raw-file/tip/testing/geckodriver/Cargo.toml'
export const BASE_CDN_URL = process.env.GECKODRIVER_CDNURL || process.env.npm_config_geckodriver_cdnurl || 'https://github.com/mozilla/geckodriver/releases/download'
// e.g. https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-macos-aarch64.tar.gz
export const GECKODRIVER_DOWNLOAD_PATH = `${BASE_CDN_URL}/v%s/geckodriver-v%s-%s%s%s`
export const DEFAULT_HOSTNAME = '0.0.0.0'
export const BINARY_FILE = 'geckodriver' + (os.platform() === 'win32' ? '.exe' : '')
export const log = logger('geckodriver')
11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cp from 'node:child_process'

import { download as downloadDriver } from './install.js'
import { hasAccess, parseParams } from './utils.js'
import { DEFAULT_HOSTNAME } from './constants.js'
import { DEFAULT_HOSTNAME, log } from './constants.js'
import type { GeckodriverParameters } from './types.js'

export async function start (params: GeckodriverParameters) {
Expand All @@ -15,10 +15,11 @@ export async function start (params: GeckodriverParameters) {
throw new Error('Failed to access Geckodriver, was it installed successfully?')
}

if (!params.host) {
params.host = DEFAULT_HOSTNAME
}
return cp.spawn(geckoDriverPath, parseParams(params))
params.host = params.host || DEFAULT_HOSTNAME

const args = parseParams(params)
log.info(`Starting Geckodriver at ${geckoDriverPath} with params: ${args.join(' ')}`)
return cp.spawn(geckoDriverPath, args)
}

export const download = downloadDriver
Expand Down
4 changes: 1 addition & 3 deletions src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ import fetch, { type RequestInit } from 'node-fetch'
import { HttpsProxyAgent } from 'https-proxy-agent'
import { HttpProxyAgent } from 'http-proxy-agent'
import unzipper, { type Entry } from 'unzipper'
import logger from '@wdio/logger'

import { BINARY_FILE, MOZ_CENTRAL_CARGO_TOML } from './constants.js'
import { BINARY_FILE, MOZ_CENTRAL_CARGO_TOML, log } from './constants.js'
import { hasAccess, getDownloadUrl } from './utils.js'

const streamPipeline = util.promisify(stream.pipeline)
const log = logger('geckodriver')

const fetchOpts: RequestInit = {}
if (process.env.HTTPS_PROXY) {
Expand Down

0 comments on commit de01d35

Please sign in to comment.