Skip to content

Commit

Permalink
Merge pull request #206 from alallier/renovate/standard-14.x
Browse files Browse the repository at this point in the history
Update dependency standard to v14
  • Loading branch information
alallier committed Oct 6, 2019
2 parents ce95d2d + c7b5aad commit ae38b01
Show file tree
Hide file tree
Showing 7 changed files with 560 additions and 409 deletions.
2 changes: 1 addition & 1 deletion lib/reload-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var reloadOpts = {
var time
var reloadReturned

var serve = serveStatic(dir, { 'index': ['index.html', 'index.htm'] })
var serve = serveStatic(dir, { index: ['index.html', 'index.htm'] })

var server = http.createServer(function (req, res) {
var url = new URL(req.url)
Expand Down
25 changes: 12 additions & 13 deletions lib/reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function reload (app, opts, server) {

// General variables
const socketPortSpecified = server ? null : port
let connections = {}
const connections = {}
let httpOrHttpsServer

if (argumentCache[0] === undefined) {
Expand Down Expand Up @@ -96,15 +96,15 @@ module.exports = function reload (app, opts, server) {
reloadCode = reloadCode.replace('verboseLogging = false', 'verboseLogging = true')
}

let webSocketString = forceWss ? 'wss://$3' : 'ws$2://$3'
const webSocketString = forceWss ? 'wss://$3' : 'ws$2://$3'

reloadCode = reloadCode.replace('socketUrl.replace()', 'socketUrl.replace(/(^http(s?):\\/\\/)(.*:)(.*)/,' + (socketPortSpecified ? '\'' + webSocketString + socketPortSpecified : '\'' + webSocketString + '$4') + '\')')
}

// Websocket server setup
function startWebSocketServer () {
let httpsOptions = {}
let WebSocketServer = ws.Server
const httpsOptions = {}
const WebSocketServer = ws.Server

return new Promise(function (resolve, reject) {
if (verboseLogging) {
Expand Down Expand Up @@ -206,7 +206,7 @@ module.exports = function reload (app, opts, server) {

// assign individual keys to connections when opened so they can be destroyed gracefully
function mapConnections (conn) {
let key = conn.remoteAddress + ':' + conn.remotePort
const key = conn.remoteAddress + ':' + conn.remotePort
connections[key] = conn

// once the connection closes, remove
Expand All @@ -216,9 +216,8 @@ module.exports = function reload (app, opts, server) {
}

function processRoute (route) {
let reloadJsMatch
// If reload.js is found in the route option strip it. We will concat it for user to ensure no case errors or order problems.
reloadJsMatch = route.match(/reload\.js/i)
const reloadJsMatch = route.match(/reload\.js/i)
if (reloadJsMatch) {
route = route.split(reloadJsMatch)[0]
}
Expand All @@ -237,15 +236,15 @@ module.exports = function reload (app, opts, server) {
}

function getReloadReturn () {
let tempObject = {
'reload': function () {
const tempObject = {
reload: function () {
sendMessage('reload')
},
'wss': wss,
'closeServer': function () {
wss: wss,
closeServer: function () {
return new Promise(function (resolve, reject) {
// Loop through all connections and terminate them for immediate server shutdown
for (let key in connections) {
for (const key in connections) {
connections[key].destroy()
}
httpOrHttpsServer.close(resolve)
Expand Down Expand Up @@ -273,7 +272,7 @@ module.exports = function reload (app, opts, server) {
if (typeof testString !== 'string') {
testString = testString.toString()
}
let lastChar = testString.substring(testString.length - 1)
const lastChar = testString.substring(testString.length - 1)
// A file path string won't have an end of line character at the end
// Looking for either \n or \r allows for nearly any OS someone could
// use, and a few that node doesn't work on.
Expand Down
Loading

0 comments on commit ae38b01

Please sign in to comment.