chromedriver 107.0.0 → 107.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/install.js +27 -25
  2. package/package.json +7 -4
package/install.js CHANGED
@@ -3,9 +3,8 @@
3
3
 
4
4
  const fs = require('fs');
5
5
  const helper = require('./lib/chromedriver');
6
- const axios = require('axios').default;
6
+ const axios = require('axios');
7
7
  const path = require('path');
8
- const del = require('del');
9
8
  const child_process = require('child_process');
10
9
  const os = require('os');
11
10
  const url = require('url');
@@ -45,9 +44,12 @@ let platform = '';
45
44
  // Refer http://chromedriver.chromium.org/downloads/version-selection
46
45
  const chromeVersion = await getChromeVersion(include_chromium);
47
46
  console.log("Your Chrome version is " + chromeVersion);
48
- const chromeVersionWithoutPatch = /^(.*?)\.\d+$/.exec(chromeVersion)[1];
49
- await getChromeDriverVersion(getRequestOptions(cdnUrl + '/LATEST_RELEASE_' + chromeVersionWithoutPatch));
50
- console.log("Compatible ChromeDriver version is " + chromedriver_version);
47
+ const versionMatch = /^(.*?)\.\d+$/.exec(chromeVersion);
48
+ if (versionMatch) {
49
+ const chromeVersionWithoutPatch = versionMatch[1];
50
+ await getChromeDriverVersion(getRequestOptions(cdnUrl + '/LATEST_RELEASE_' + chromeVersionWithoutPatch));
51
+ console.log("Compatible ChromeDriver version is " + chromedriver_version);
52
+ }
51
53
  }
52
54
  if (chromedriver_version === 'LATEST') {
53
55
  await getChromeDriverVersion(getRequestOptions(`${cdnUrl}/LATEST_RELEASE`));
@@ -163,11 +165,10 @@ function findSuitableTempDirectory() {
163
165
  path.join(process.cwd(), 'tmp')
164
166
  ];
165
167
 
166
- for (let i = 0; i < candidateTmpDirs.length; i++) {
167
- if (!candidateTmpDirs[i]) continue;
168
- // Prevent collision with other versions in the dependency tree
168
+ for (const tempDir of candidateTmpDirs) {
169
+ if (!tempDir) continue;
169
170
  const namespace = chromedriver_version;
170
- const candidatePath = path.join(candidateTmpDirs[i], namespace, 'chromedriver');
171
+ const candidatePath = path.join(tempDir, namespace, 'chromedriver');
171
172
  try {
172
173
  fs.mkdirSync(candidatePath, { recursive: true });
173
174
  const testFile = path.join(candidatePath, now + '.tmp');
@@ -191,11 +192,12 @@ function getRequestOptions(downloadPath) {
191
192
 
192
193
  if (proxyUrl) {
193
194
  const proxyUrlParts = url.parse(proxyUrl);
194
- options.proxy = {
195
- host: proxyUrlParts.hostname,
196
- port: proxyUrlParts.port ? parseInt(proxyUrlParts.port) : 80,
197
- protocol: proxyUrlParts.protocol
198
- };
195
+ if (proxyUrlParts.hostname && proxyUrlParts.protocol)
196
+ options.proxy = {
197
+ host: proxyUrlParts.hostname,
198
+ port: proxyUrlParts.port ? parseInt(proxyUrlParts.port) : 80,
199
+ protocol: proxyUrlParts.protocol
200
+ };
199
201
  }
200
202
 
201
203
  if (isHttps) {
@@ -245,7 +247,7 @@ function getRequestOptions(downloadPath) {
245
247
  */
246
248
  async function getChromeDriverVersion(requestOptions) {
247
249
  console.log('Finding Chromedriver version.');
248
- const response = await axios(requestOptions);
250
+ const response = await axios.request(requestOptions);
249
251
  chromedriver_version = response.data.trim();
250
252
  console.log(`Chromedriver version is ${chromedriver_version}.`);
251
253
  }
@@ -259,7 +261,7 @@ async function requestBinary(requestOptions, filePath) {
259
261
  const outFile = fs.createWriteStream(filePath);
260
262
  let response;
261
263
  try {
262
- response = await axios({ responseType: 'stream', ...requestOptions });
264
+ response = await axios.request({ responseType: 'stream', ...requestOptions });
263
265
  } catch (error) {
264
266
  if (error && error.response) {
265
267
  if (error.response.status)
@@ -267,7 +269,7 @@ async function requestBinary(requestOptions, filePath) {
267
269
  if (error.response.data) {
268
270
  error.response.data.on('data', data => console.error(data.toString('utf8')));
269
271
  try {
270
- await finishedAsync(error.response.data)
272
+ await finishedAsync(error.response.data);
271
273
  } catch (error) {
272
274
  console.error('Error downloading entire response:', error);
273
275
  }
@@ -307,7 +309,7 @@ async function extractDownload(dirToExtractTo) {
307
309
  }
308
310
 
309
311
  async function copyIntoPlace(originPath, targetPath) {
310
- await del(targetPath, { force: true });
312
+ fs.rmSync(targetPath, { recursive: true, force: true });
311
313
  console.log(`Copying from ${originPath} to target path ${targetPath}`);
312
314
  fs.mkdirSync(targetPath);
313
315
 
@@ -316,14 +318,14 @@ async function copyIntoPlace(originPath, targetPath) {
316
318
  .filter(dirent => dirent.isFile() && dirent.name.startsWith('chromedriver') && !dirent.name.endsWith(".debug") && !dirent.name.endsWith(".zip"))
317
319
  .map(dirent => dirent.name);
318
320
  const promises = files.map(name => {
319
- return new Promise((resolve) => {
321
+ return /** @type {Promise<void>} */(new Promise((resolve) => {
320
322
  const file = path.join(originPath, name);
321
323
  const reader = fs.createReadStream(file);
322
324
  const targetFile = path.join(targetPath, name);
323
325
  const writer = fs.createWriteStream(targetFile);
324
326
  writer.on("close", () => resolve());
325
327
  reader.pipe(writer);
326
- });
328
+ }));
327
329
  });
328
330
  await Promise.all(promises);
329
331
  }
@@ -347,7 +349,7 @@ function getMacOsRealArch() {
347
349
  return 'mac64_m1';
348
350
  }
349
351
 
350
- return 'mac_arm64'
352
+ return 'mac_arm64';
351
353
  }
352
354
 
353
355
  if (process.arch === 'x64') {
@@ -364,14 +366,14 @@ function isEmulatedRosettaEnvironment() {
364
366
  const proc = child_process.spawnSync('sysctl', ['-in', 'sysctl.proc_translated']);
365
367
 
366
368
  // When run with `-in`, the return code is 0 even if there is no `sysctl.proc_translated`
367
- if(proc.status) {
368
- throw new Error('Unexpected return code from sysctl: ' + proc.status);
369
+ if (proc.status) {
370
+ throw new Error('Unexpected return code from sysctl: ' + proc.status);
369
371
  }
370
372
 
371
373
  // If there is no `sysctl.proc_translated` (i.e. not rosetta) then nothing is printed to
372
374
  // stdout
373
- if(!proc.stdout) {
374
- return false
375
+ if (!proc.stdout) {
376
+ return false;
375
377
  }
376
378
 
377
379
  const processTranslated = proc.stdout.toString().trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chromedriver",
3
- "version": "107.0.0",
3
+ "version": "107.0.2",
4
4
  "keywords": [
5
5
  "chromedriver",
6
6
  "selenium"
@@ -23,18 +23,21 @@
23
23
  },
24
24
  "scripts": {
25
25
  "install": "node install.js",
26
- "update-chromedriver": "node update.js"
26
+ "update-chromedriver": "node update.js",
27
+ "lint": "eslint"
27
28
  },
28
29
  "dependencies": {
29
30
  "@testim/chrome-version": "^1.1.3",
30
- "axios": "^0.27.2",
31
+ "axios": "^1.1.3",
31
32
  "compare-versions": "^5.0.1",
32
- "del": "^6.1.1",
33
33
  "extract-zip": "^2.0.1",
34
34
  "https-proxy-agent": "^5.0.1",
35
35
  "proxy-from-env": "^1.1.0",
36
36
  "tcp-port-used": "^1.0.1"
37
37
  },
38
+ "devDependencies": {
39
+ "eslint": "^8.26.0"
40
+ },
38
41
  "engines": {
39
42
  "node": ">=10"
40
43
  }