Skip to content

Commit

Permalink
[JS] Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
harsha509 committed Feb 16, 2021
1 parent dccf4dd commit dcfc437
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
13 changes: 6 additions & 7 deletions javascript/node/selenium-webdriver/lib/test/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
const fs = require('fs')
const path = require('path')
const { spawn } = require('child_process')

const PROJECT_ROOT = path.normalize(path.join(__dirname, '../../../../..'))
const WORKSPACE_FILE = path.join(PROJECT_ROOT, 'WORKSPACE')

Expand All @@ -38,14 +37,14 @@ function checkIsDevMode() {
* Targets that have been previously built.
* @type {!Object}
*/
var builtTargets = {}
let builtTargets = {}

/**
* @param {!Array.<string>} targets The targets to build.
* @throws {Error} If not running in dev mode.
* @constructor
*/
var Build = function (targets) {
const Build = function (targets) {
checkIsDevMode()
this.targets_ = targets
}
Expand All @@ -70,7 +69,7 @@ Build.prototype.onlyOnce = function () {
* @throws {Error} If no targets were specified.
*/
Build.prototype.go = function () {
var targets = this.targets_
let targets = this.targets_
if (!targets.length) {
throw Error('No targets specified')
}
Expand All @@ -88,7 +87,7 @@ Build.prototype.go = function () {

console.log('\nBuilding', targets.join(' '), '...')

var cmd,
let cmd,
args = targets
if (process.platform === 'win32') {
cmd = 'cmd.exe'
Expand All @@ -110,7 +109,7 @@ Build.prototype.go = function () {
return resolve()
}

var msg = 'Unable to build artifacts'
let msg = 'Unable to build artifacts'
if (code) {
// May be null.
msg += '; code=' + code
Expand All @@ -135,7 +134,7 @@ exports.isDevMode = isDevMode
* @throws {Error} If not running in dev mode.
*/
exports.of = function (var_args) { // eslint-disable-line
var targets = Array.prototype.slice.call(arguments, 0)
let targets = Array.prototype.slice.call(arguments, 0)
return new Build(targets)
}

Expand Down
18 changes: 9 additions & 9 deletions javascript/node/selenium-webdriver/lib/test/httpserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

'use strict'

var assert = require('assert'),
const assert = require('assert'),
http = require('http'),
url = require('url')

var net = require('../../net'),
const net = require('../../net'),
portprober = require('../../net/portprober'),
promise = require('../..').promise

Expand All @@ -32,8 +32,8 @@ var net = require('../../net'),
* The request handler for the server.
* @constructor
*/
var Server = function (requestHandler) {
var server = http.createServer(function (req, res) {
let Server = function (requestHandler) {
let server = http.createServer(function (req, res) {
requestHandler(req, res)
})

Expand All @@ -42,7 +42,7 @@ var Server = function (requestHandler) {
})

/** @typedef {{port: number, address: string, family: string}} */
var Host // eslint-disable-line
let Host // eslint-disable-line

/**
* Starts the server on the given port. If no port, or 0, is provided,
Expand All @@ -56,7 +56,7 @@ var Server = function (requestHandler) {
typeof opt_port !== 'function',
'start invoked with function, not port (mocha callback)?'
)
var port = opt_port || portprober.findFreePort('localhost')
const port = opt_port || portprober.findFreePort('localhost')
return Promise.resolve(port)
.then((port) => {
return promise.checkedNodeCall(
Expand All @@ -82,7 +82,7 @@ var Server = function (requestHandler) {
* @throws {Error} If the server is not running.
*/
this.address = function () {
var addr = server.address()
const addr = server.address()
if (!addr) {
throw Error('There server is not running!')
}
Expand All @@ -104,8 +104,8 @@ var Server = function (requestHandler) {
* @throws {Error} If the server is not running.
*/
this.url = function (opt_pathname) {
var addr = this.address()
var pathname = opt_pathname || ''
const addr = this.address()
const pathname = opt_pathname || ''
return url.format({
protocol: 'http',
hostname: net.getLoopbackAddress(),
Expand Down
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/lib/test/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const { projectRoot } = require('./build')
* @throws {Error} If the file does not exist.
*/
exports.locate = function (filePath) {
var fullPath = path.normalize(path.join(projectRoot(), filePath))
const fullPath = path.normalize(path.join(projectRoot(), filePath))
if (!fs.existsSync(fullPath)) {
throw Error('File does not exist: ' + filePath)
}
Expand Down

0 comments on commit dcfc437

Please sign in to comment.