Skip to content

Commit

Permalink
chore/update code format, remove one place package usage (#845)
Browse files Browse the repository at this point in the history
  • Loading branch information
potapovDim committed Sep 17, 2023
1 parent b6bc0d6 commit 2f3b7af
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 96 deletions.
14 changes: 6 additions & 8 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ updates:
open-pull-requests-limit: 10
versioning-strategy: increase-if-necessary
ignore:
- dependency-name: "fs-extra"
update-types: ["version-update:semver-major"]
- dependency-name: "got"
update-types: ["version-update:semver-major"]
- dependency-name: "mocha"
Expand All @@ -25,14 +23,14 @@ updates:
- dependency-name: "eslint-plugin-prettier"
update-types: ["version-update:semver-major"]
- dependency-name: "eslint"
update-types: ["version-update:semver-major"]
update-types: ["version-update:semver-major"]
- dependency-name: "execa"
update-types: ["version-update:semver-major"]
update-types: ["version-update:semver-major"]
- dependency-name: "find-process"
update-types: ["version-update:semver-major"]
update-types: ["version-update:semver-major"]
- dependency-name: "fkill"
update-types: ["version-update:semver-major"]
update-types: ["version-update:semver-major"]
- dependency-name: "prettier"
update-types: ["version-update:semver-major"]
update-types: ["version-update:semver-major"]



22 changes: 9 additions & 13 deletions lib/check-paths-existence.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
module.exports = checkPathsExistence;
const fs = require('fs');

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

async function checkPathsExistence(paths) {
const pathValues = Object.keys(paths).map((key) => {
return paths[key];
pathValues.forEach((path) => {
if (!fs.existsSync(path)) {
throw new Error('Missing ' + path);
}
});
};

return Promise.all(
pathValues.map(async (path) => {
if (!(await fse.pathExists(path))) {
throw new Error('Missing ' + path);
}
})
);
}
module.exports = checkPathsExistence;
4 changes: 2 additions & 2 deletions lib/compute-download-urls.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
module.exports = { computeDownloadUrls, resolveDownloadPath, getLastChromedriverVersionFromMajor, getLatestChromium };

const got = require('got');
const util = require('util');
const { isSelenium4 } = require('./isSelenium4');
Expand Down Expand Up @@ -343,3 +341,5 @@ async function getPackageInfo(version, arh, channel, baseUrl) {

return { latestVersion, url };
}

module.exports = { computeDownloadUrls, resolveDownloadPath, getLastChromedriverVersionFromMajor, getLatestChromium };
8 changes: 4 additions & 4 deletions lib/compute-fs-paths.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
module.exports = computeFsPaths;

const path = require('path');
const { getLastChromedriverVersionFromMajor, getLatestChromium } = require('./compute-download-urls');
const { validateMajorVersionPrefix } = require('./validation');
const { detectBrowserPlatformCustom } = require('./platformDetection');

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

async function computeFsPaths(options) {
const computeFsPaths = async (options) => {
let fsPaths = {};
const opts = Object.assign({}, options);
opts.basePath = opts.basePath || basePath;
Expand Down Expand Up @@ -104,4 +102,6 @@ async function computeFsPaths(options) {
}, fsPaths);

return fsPaths;
}
};

module.exports = computeFsPaths;
22 changes: 13 additions & 9 deletions lib/get-selenium-status-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,25 @@ const PROCESS_TYPES = {
GRID_NODE: 2,
DISTRIBUTOR_NODE: 3,
};
exports.PROCESS_TYPES = PROCESS_TYPES;

function parseRole(role) {
const parseRole = (role) => {
if (!role || role === 'standalone') return PROCESS_TYPES.STANDALONE;
if (role === 'hub') return PROCESS_TYPES.GRID_HUB;
if (role === 'node') return PROCESS_TYPES.GRID_NODE;
if (role === 'distributor') return PROCESS_TYPES.DISTRIBUTOR_NODE;
return undefined;
}
};

function getDefaultPort(processType) {
const getDefaultPort = (processType) => {
switch (processType) {
case PROCESS_TYPES.STANDALONE:
case PROCESS_TYPES.GRID_HUB:
return 4444;
case PROCESS_TYPES.GRID_NODE:
return 5555;
}
}
};

exports.getRunningProcessType = function (seleniumArgs) {
const getRunningProcessType = (seleniumArgs) => {
const roleArg = Math.max(
seleniumArgs.indexOf('hub'),
seleniumArgs.indexOf('node'),
Expand All @@ -44,7 +42,7 @@ exports.getRunningProcessType = function (seleniumArgs) {
* @param {object} opts
* @returns {URL}
*/
exports.getSeleniumStatusUrl = function (seleniumArgs, opts) {
const getSeleniumStatusUrl = (seleniumArgs, opts) => {
const nodeConfigArg = seleniumArgs.indexOf('-nodeConfig');

// args prefix differs for selenium3 and selenium4
Expand All @@ -58,7 +56,7 @@ exports.getSeleniumStatusUrl = function (seleniumArgs, opts) {
let host = 'localhost';
let port;
let config;
let processType = this.getRunningProcessType(seleniumArgs);
let processType = getRunningProcessType(seleniumArgs);

// If node config path is pass via -nodeConfig, we have to take settings from there,
// and override them with possible command line options, as later ones have higher priority
Expand Down Expand Up @@ -109,3 +107,9 @@ exports.getSeleniumStatusUrl = function (seleniumArgs, opts) {
statusURI.port = port || getDefaultPort(processType);
return statusURI;
};

module.exports = {
getSeleniumStatusUrl,
getRunningProcessType,
PROCESS_TYPES,
};
63 changes: 4 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"execa": "^5.1.1",
"find-process": "^1.4.7",
"fkill": "^7.2.1",
"fs-extra": "^10.0.0",
"got": "^11.8.2",
"is-port-reachable": "^3.0.0",
"lodash.mapvalues": "^4.6.0",
Expand Down

0 comments on commit 2f3b7af

Please sign in to comment.