From d335c344bba99981387672bef8da45bdd77825eb Mon Sep 17 00:00:00 2001 From: Christian Bromann Date: Mon, 11 Dec 2023 16:50:43 -0800 Subject: [PATCH] fix build --- src/constants.ts | 2 -- src/index.ts | 5 ++++- src/install.ts | 4 +++- src/utils.ts | 4 ++-- tsconfig.json | 5 ++--- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 05672ea..b614e00 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,5 +1,4 @@ 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' @@ -7,4 +6,3 @@ export const BASE_CDN_URL = process.env.GECKODRIVER_CDNURL || process.env.npm_co 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') diff --git a/src/index.ts b/src/index.ts index f6fd170..e553191 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,13 @@ import cp from 'node:child_process' +import logger from '@wdio/logger' import { download as downloadDriver } from './install.js' import { hasAccess, parseParams } from './utils.js' -import { DEFAULT_HOSTNAME, log } from './constants.js' +import { DEFAULT_HOSTNAME } from './constants.js' import type { GeckodriverParameters } from './types.js' +const log = logger('geckodriver') + export async function start (params: GeckodriverParameters) { const { cacheDir, customGeckoDriverPath, ...startArgs } = params let geckoDriverPath = process.env.GECKODRIVER_FILEPATH || customGeckoDriverPath diff --git a/src/install.ts b/src/install.ts index 5b15476..d299e8b 100644 --- a/src/install.ts +++ b/src/install.ts @@ -7,15 +7,17 @@ import fsp from 'node:fs/promises' import zlib from 'node:zlib' import { Readable } from 'node:stream' +import logger from '@wdio/logger' import tar from 'tar-fs' import { type RequestInit } from 'node-fetch' import { HttpsProxyAgent } from 'https-proxy-agent' import { HttpProxyAgent } from 'http-proxy-agent' import unzipper, { type Entry } from 'unzipper' -import { BINARY_FILE, MOZ_CENTRAL_CARGO_TOML, log } from './constants.js' +import { BINARY_FILE, MOZ_CENTRAL_CARGO_TOML } from './constants.js' import { hasAccess, getDownloadUrl, retryFetch } from './utils.js' +const log = logger('geckodriver') const streamPipeline = util.promisify(stream.pipeline) const fetchOpts: RequestInit = {} diff --git a/src/utils.ts b/src/utils.ts index 956248e..1655101 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -39,8 +39,8 @@ export function parseParams(params: GeckodriverParameters) { if (typeof val === 'boolean' && !val) { return '' } - const vals = Array.isArray(val) ? val : [val] - return vals.map((v) => `--${decamelize(key, { separator: '-' })}${typeof v === 'boolean' ? '' : `=${v}`}`) + const values = Array.isArray(val) ? val : [val] + return values.map((v) => `--${decamelize(key, { separator: '-' })}${typeof v === 'boolean' ? '' : `=${v}`}`) }) .flat() .filter(Boolean) diff --git a/tsconfig.json b/tsconfig.json index 2205ef3..3f29e65 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,10 @@ { "compilerOptions": { - "module": "ESNext", + "module": "NodeNext", "target": "ES2020", "baseUrl": "src", "outDir": "./dist", - "moduleResolution": "node", + "moduleResolution": "Node16", "declaration": true, "declarationMap": true, "noUnusedLocals": true, @@ -23,4 +23,3 @@ "include": ["src/**/*", "src/cjs/package.json"], "ignore": ["node_modules", "dist"] } - \ No newline at end of file