uclabruins-preview
Advanced tools
Comparing version 1.2.0 to 1.2.1
14
app.js
@@ -94,3 +94,3 @@ #! /usr/bin/env node | ||
console.log('serving preview of ' + pageFile + ' at http://localhost:' + port); | ||
server = http.createServer(function(req, res){ | ||
server = http.createServer((req, res) => { | ||
const uri = url.parse(req.url).pathname; | ||
@@ -103,3 +103,3 @@ const filename = path.join(process.cwd(), uri); | ||
else { | ||
fs.exists(filename, function(exists) { | ||
fs.exists(filename, exists => { | ||
if (!exists) { | ||
@@ -111,3 +111,3 @@ res.writeHead(404, {"Content-Type": "text/plain"}); | ||
else { | ||
fs.readFile(filename, "binary", function(err, file) { | ||
fs.readFile(filename, "binary", (err, file) => { | ||
if (err) { | ||
@@ -128,3 +128,3 @@ res.writeHead(500, {"Content-Type": "text/plain"}); | ||
// from restarting | ||
req.connection.destroy(); | ||
setTimeout(() => { req.connection.destroy() }, 10*1000); | ||
}).listen(port, 'localhost'); | ||
@@ -135,8 +135,8 @@ } | ||
chokidar.watch(pageFile).on('change', function(){ | ||
chokidar.watch(pageFile).on('change', () => { | ||
// listen for changes to the page file. if it changes, stop and restart the server. | ||
var date = new Date(); | ||
var formattedTime = [date.getHours(), date.getMinutes(), date.getSeconds()].join(':'); | ||
const date = new Date(); | ||
const formattedTime = [date.getHours(), date.getMinutes(), date.getSeconds()].join(':'); | ||
console.log('[' + formattedTime + '] ' + 'detected change, reloading...'); | ||
server.close(readPage); // invoke readPage as a callback once server is closed | ||
}); |
{ | ||
"name": "uclabruins-preview", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Preview pages on uclabruins.com.", | ||
@@ -5,0 +5,0 @@ "main": "app.js", |
5567