New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

reload

Package Overview
Dependencies
Maintainers
3
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reload - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

5

CHANGELOG.md

@@ -0,1 +1,6 @@

2.2.0 / 2017-07-27
------------------
* Dropped express as a dependency (in reload command line). Reload now uses a vanilla node http server to achieve the same result. This update for the command line offers no changes to the end user and simply modifies the underlying code. See: https://github.com/alallier/reload/pull/132
2.1.0 / 2017-07-25

@@ -2,0 +7,0 @@ ------------------

67

lib/reload-server.js

@@ -1,2 +0,1 @@

var express = require('express')
var http = require('http')

@@ -10,4 +9,2 @@ var path = require('path')

var app = express()
var port = argv._[0]

@@ -23,22 +20,26 @@ var dir = argv._[1]

port: port,
verbose: verbose
verbose: verbose,
noExpress: true
}
var time
var reloadReturned
var router = express.Router()
var server = http.createServer(function (req, res) {
var file
var reqUrl = req.url
app.set('port', port)
if (reqUrl === '/') {
file = path.join(dir, startPage)
} else {
file = path.join(dir, reqUrl) + '.html'
}
router.get('/', function (req, res, next) {
// Create the start page path.
var startFile = path.join(dir, startPage)
fs.access(startFile, function (err) {
// If the start page doesn't exist (whether it's the deault index.html or specified).
if (err) {
res.status(404).send("Can't find " + startPage)
appendReloadClientCode(file, function (contents) {
if (contents) {
res.writeHead(200, {'Content-Type': 'text/html; charset=UTF-8'})
res.end(contents)
} else {
// Else the start page exists send the reload-client code to the HTML.
sendhtml(startFile, res)
res.writeHead(404, {'Content-Type': 'text/plain; charset=UTF-8'})
res.end('File Not Found')
}

@@ -48,20 +49,6 @@ })

// Routing for any HTML, so that we can send the reload-client file to every HTML page when naviagted too.
router.get('*.html', function (req, res) {
// This wouldn't be efficient in any other context.
var file = path.join(dir, req.url)
sendhtml(file, res)
})
// Reload call and configurations. Stub app as it isn't used here
reloadReturned = reload(function () {}, reloadOpts, server)
app.use('/', router)
app.use('*html', router)
app.use(express.static(dir)) // Should cache static assets.
var server = http.createServer(app)
// Reload call and configurations.
reload(app, reloadOpts, server)
server.listen(app.get('port'), function () {
server.listen(port, function () {
if (!fs.existsSync(runFile)) {

@@ -72,3 +59,3 @@ fs.writeFileSync(runFile)

if (openBrowser) {
open('http://' + hostname + ':' + app.get('port'))
open('http://' + hostname + ':' + port)
}

@@ -82,13 +69,13 @@ } else {

// Function to send reload-client code to the browser.
function sendhtml (file, res) {
function appendReloadClientCode (file, next) {
fs.readFile(file, 'utf8', function (err, contents) {
if (err) {
console.error(err)
process.exit(1)
next(null)
}
var reloadClientCode = reloadReturned.reloadClientCode()
contents += '\n\n<!-- Inserted by Reload -->\n<script src="/reload/reload.js"></script>\n<!-- End Reload -->\n'
res.type('text/html')
res.send(contents)
contents += '\n\n<!-- Inserted by Reload -->\n<script>' + reloadClientCode + '</script>\n<!-- End Reload -->\n'
next(contents)
})
}

@@ -90,6 +90,8 @@ module.exports = function reload (app, opts, server) {

expressApp.get(route, function (req, res) {
res.type('text/javascript')
res.send(reloadCode)
})
if (!server) {
expressApp.get(route, function (req, res) {
res.type('text/javascript')
res.send(reloadCode)
})
}

@@ -135,2 +137,7 @@ if (!webSocketServerWaitStart) {

},
'reloadClientCode': function () {
if (server) {
return reloadCode
}
},
'startWebSocketServer': function () {

@@ -137,0 +144,0 @@ if (webSocketServerWaitStart) {

{
"name": "reload",
"version": "2.1.0",
"version": "2.2.0",
"description": "Node.js module to refresh and reload your code in your browser when your code changes. No browser plugins required.",

@@ -24,3 +24,2 @@ "repository": {

"commander": "~2.9.0",
"express": "~4.15.3",
"cli-color": "~1.2.0",

@@ -27,0 +26,0 @@ "open": "~0.0.5",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc