Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency standard to v14 #206

Merged
merged 4 commits into from
Oct 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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