Skip to content

Commit 2f3b7af

Browse files
authored
chore/update code format, remove one place package usage (#845)
1 parent b6bc0d6 commit 2f3b7af

File tree

7 files changed

+38
-96
lines changed

7 files changed

+38
-96
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ updates:
88
open-pull-requests-limit: 10
99
versioning-strategy: increase-if-necessary
1010
ignore:
11-
- dependency-name: "fs-extra"
12-
update-types: ["version-update:semver-major"]
1311
- dependency-name: "got"
1412
update-types: ["version-update:semver-major"]
1513
- dependency-name: "mocha"
@@ -25,14 +23,14 @@ updates:
2523
- dependency-name: "eslint-plugin-prettier"
2624
update-types: ["version-update:semver-major"]
2725
- dependency-name: "eslint"
28-
update-types: ["version-update:semver-major"]
26+
update-types: ["version-update:semver-major"]
2927
- dependency-name: "execa"
30-
update-types: ["version-update:semver-major"]
28+
update-types: ["version-update:semver-major"]
3129
- dependency-name: "find-process"
32-
update-types: ["version-update:semver-major"]
30+
update-types: ["version-update:semver-major"]
3331
- dependency-name: "fkill"
34-
update-types: ["version-update:semver-major"]
32+
update-types: ["version-update:semver-major"]
3533
- dependency-name: "prettier"
36-
update-types: ["version-update:semver-major"]
34+
update-types: ["version-update:semver-major"]
35+
3736

38-

lib/check-paths-existence.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
module.exports = checkPathsExistence;
1+
const fs = require('fs');
22

3-
const fse = require('fs-extra');
3+
const checkPathsExistence = (paths) => {
4+
const pathValues = Object.values(paths);
45

5-
async function checkPathsExistence(paths) {
6-
const pathValues = Object.keys(paths).map((key) => {
7-
return paths[key];
6+
pathValues.forEach((path) => {
7+
if (!fs.existsSync(path)) {
8+
throw new Error('Missing ' + path);
9+
}
810
});
11+
};
912

10-
return Promise.all(
11-
pathValues.map(async (path) => {
12-
if (!(await fse.pathExists(path))) {
13-
throw new Error('Missing ' + path);
14-
}
15-
})
16-
);
17-
}
13+
module.exports = checkPathsExistence;

lib/compute-download-urls.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
module.exports = { computeDownloadUrls, resolveDownloadPath, getLastChromedriverVersionFromMajor, getLatestChromium };
2-
31
const got = require('got');
42
const util = require('util');
53
const { isSelenium4 } = require('./isSelenium4');
@@ -343,3 +341,5 @@ async function getPackageInfo(version, arh, channel, baseUrl) {
343341

344342
return { latestVersion, url };
345343
}
344+
345+
module.exports = { computeDownloadUrls, resolveDownloadPath, getLastChromedriverVersionFromMajor, getLatestChromium };

lib/compute-fs-paths.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
module.exports = computeFsPaths;
2-
31
const path = require('path');
42
const { getLastChromedriverVersionFromMajor, getLatestChromium } = require('./compute-download-urls');
53
const { validateMajorVersionPrefix } = require('./validation');
64
const { detectBrowserPlatformCustom } = require('./platformDetection');
75

86
const basePath = path.join(__dirname, '..', '.selenium');
97

10-
async function computeFsPaths(options) {
8+
const computeFsPaths = async (options) => {
119
let fsPaths = {};
1210
const opts = Object.assign({}, options);
1311
opts.basePath = opts.basePath || basePath;
@@ -104,4 +102,6 @@ async function computeFsPaths(options) {
104102
}, fsPaths);
105103

106104
return fsPaths;
107-
}
105+
};
106+
107+
module.exports = computeFsPaths;

lib/get-selenium-status-url.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,25 @@ const PROCESS_TYPES = {
77
GRID_NODE: 2,
88
DISTRIBUTOR_NODE: 3,
99
};
10-
exports.PROCESS_TYPES = PROCESS_TYPES;
1110

12-
function parseRole(role) {
11+
const parseRole = (role) => {
1312
if (!role || role === 'standalone') return PROCESS_TYPES.STANDALONE;
1413
if (role === 'hub') return PROCESS_TYPES.GRID_HUB;
1514
if (role === 'node') return PROCESS_TYPES.GRID_NODE;
1615
if (role === 'distributor') return PROCESS_TYPES.DISTRIBUTOR_NODE;
17-
return undefined;
18-
}
16+
};
1917

20-
function getDefaultPort(processType) {
18+
const getDefaultPort = (processType) => {
2119
switch (processType) {
2220
case PROCESS_TYPES.STANDALONE:
2321
case PROCESS_TYPES.GRID_HUB:
2422
return 4444;
2523
case PROCESS_TYPES.GRID_NODE:
2624
return 5555;
2725
}
28-
}
26+
};
2927

30-
exports.getRunningProcessType = function (seleniumArgs) {
28+
const getRunningProcessType = (seleniumArgs) => {
3129
const roleArg = Math.max(
3230
seleniumArgs.indexOf('hub'),
3331
seleniumArgs.indexOf('node'),
@@ -44,7 +42,7 @@ exports.getRunningProcessType = function (seleniumArgs) {
4442
* @param {object} opts
4543
* @returns {URL}
4644
*/
47-
exports.getSeleniumStatusUrl = function (seleniumArgs, opts) {
45+
const getSeleniumStatusUrl = (seleniumArgs, opts) => {
4846
const nodeConfigArg = seleniumArgs.indexOf('-nodeConfig');
4947

5048
// args prefix differs for selenium3 and selenium4
@@ -58,7 +56,7 @@ exports.getSeleniumStatusUrl = function (seleniumArgs, opts) {
5856
let host = 'localhost';
5957
let port;
6058
let config;
61-
let processType = this.getRunningProcessType(seleniumArgs);
59+
let processType = getRunningProcessType(seleniumArgs);
6260

6361
// If node config path is pass via -nodeConfig, we have to take settings from there,
6462
// and override them with possible command line options, as later ones have higher priority
@@ -109,3 +107,9 @@ exports.getSeleniumStatusUrl = function (seleniumArgs, opts) {
109107
statusURI.port = port || getDefaultPort(processType);
110108
return statusURI;
111109
};
110+
111+
module.exports = {
112+
getSeleniumStatusUrl,
113+
getRunningProcessType,
114+
PROCESS_TYPES,
115+
};

package-lock.json

Lines changed: 4 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
"execa": "^5.1.1",
4747
"find-process": "^1.4.7",
4848
"fkill": "^7.2.1",
49-
"fs-extra": "^10.0.0",
5049
"got": "^11.8.2",
5150
"is-port-reachable": "^3.0.0",
5251
"lodash.mapvalues": "^4.6.0",

0 commit comments

Comments
 (0)