live-server
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -21,7 +21,7 @@ #!/usr/bin/env node | ||
.replace(/"/g, '"'); | ||
}; | ||
} | ||
// Based on connect.static(), but streamlined and with added code injecter | ||
function static(root) { | ||
return function static(req, res, next) { | ||
function staticServer(root) { | ||
return function(req, res, next) { | ||
if ('GET' != req.method && 'HEAD' != req.method) return next(); | ||
@@ -44,3 +44,3 @@ var reqpath = url.parse(req.url).pathname; | ||
var x = path.extname(reqpath); | ||
if (x == "" || x == ".html" || x == ".htm" || x == ".xhtml" || x == ".php") { | ||
if (x === "" || x == ".html" || x == ".htm" || x == ".xhtml" || x == ".php") { | ||
// We need to modify the length given to browser | ||
@@ -61,3 +61,3 @@ var len = INJECTED_CODE.length + res.getHeader('Content-Length'); | ||
}; | ||
}; | ||
} | ||
@@ -69,3 +69,4 @@ function start(port, directory) { | ||
var app = connect() | ||
.use(static(directory)) // Custom static server | ||
.use(staticServer(directory)) // Custom static server | ||
.use(connect.directory(directory, { icons: true })) | ||
.use(connect.logger('dev')); | ||
@@ -76,3 +77,3 @@ var server = http.createServer(app).listen(port); | ||
ws = new WebSocket(request, socket, head); | ||
ws.onopen = function() { ws.send('connected'); } | ||
ws.onopen = function() { ws.send('connected'); }; | ||
}); | ||
@@ -79,0 +80,0 @@ // Setup file watcher |
{ | ||
"name": "live-server", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "simple development http server with live reload capability", | ||
@@ -22,2 +22,5 @@ "keywords": [ | ||
}, | ||
"scripts": { | ||
"test": "jshint *.js" | ||
}, | ||
"bin": { | ||
@@ -24,0 +27,0 @@ "live-server": "./live-server.js" |
@@ -55,2 +55,16 @@ Live Server | ||
Version history | ||
--------------- | ||
* v0.3.0 | ||
- Directory listings | ||
* v0.2.0 | ||
- On-the-fly CSS refresh (no page reload) | ||
- Refactoring | ||
* v0.1.1 | ||
- Documentation and meta tweaks | ||
* v0.1.0 | ||
- Initial release | ||
License | ||
@@ -57,0 +71,0 @@ ------- |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7650
83
83