connect-livereload
Advanced tools
Comparing version 0.5.2 to 0.5.3
48
index.js
@@ -5,4 +5,4 @@ module.exports = function livereload(opt) { | ||
var ignore = opt.ignore || opt.excludeList || [/\.js(\?.*)?$/, /\.css(\?.*)?$/, /\.svg(\?.*)?$/, /\.ico(\?.*)?$/, | ||
/\.woff(\?.*)?$/, /\.png(\?.*)?$/, /\.jpg(\?.*)?$/, /\.jpeg(\?.*)?$/, /\.gif(\?.*)?$/, /\.pdf(\?.*)?$/ | ||
]; | ||
/\.woff(\?.*)?$/, /\.png(\?.*)?$/, /\.jpg(\?.*)?$/, /\.jpeg(\?.*)?$/, /\.gif(\?.*)?$/, /\.pdf(\?.*)?$/ | ||
]; | ||
@@ -12,11 +12,11 @@ var include = opt.include || [/.*/]; | ||
var rules = opt.rules || [{ | ||
match: /<\/body>(?![\s\S]*<\/body>)/i, | ||
fn: prepend | ||
}, { | ||
match: /<\/html>(?![\s\S]*<\/html>)/i, | ||
fn: prepend | ||
}, { | ||
match: /<\!DOCTYPE.+?>/i, | ||
fn: append | ||
}]; | ||
match: /<\/body>(?![\s\S]*<\/body>)/i, | ||
fn: prepend | ||
}, { | ||
match: /<\/html>(?![\s\S]*<\/html>)/i, | ||
fn: prepend | ||
}, { | ||
match: /<\!DOCTYPE.+?>/i, | ||
fn: append | ||
}]; | ||
var disableCompression = opt.disableCompression || false; | ||
@@ -29,4 +29,4 @@ var hostname = opt.hostname || 'localhost'; | ||
// helper functions | ||
var regex = (function() { | ||
var matches = rules.map(function(item) { | ||
var regex = (function () { | ||
var matches = rules.map(function (item) { | ||
return item.match.source; | ||
@@ -63,5 +63,5 @@ }).join('|'); | ||
var _body = body; | ||
rules.some(function(rule) { | ||
rules.some(function (rule) { | ||
if (rule.match.test(body)) { | ||
_body = body.replace(rule.match, function(w) { | ||
_body = body.replace(rule.match, function (w) { | ||
return rule.fn(w, snippet); | ||
@@ -84,3 +84,3 @@ }); | ||
if (!str) return true; | ||
return arr.some(function(item) { | ||
return arr.some(function (item) { | ||
if ((item.test && item.test(str)) || ~str.indexOf(item)) return true; | ||
@@ -110,8 +110,8 @@ return false; | ||
res.push = function(chunk) { | ||
res.push = function (chunk) { | ||
res.data = (res.data || '') + chunk; | ||
}; | ||
res.inject = res.write = function(string, encoding) { | ||
if(!runPatches) return write.call(res, string, encoding); | ||
res.inject = res.write = function (string, encoding) { | ||
if (!runPatches) return write.call(res, string, encoding); | ||
@@ -134,4 +134,4 @@ if (string !== undefined) { | ||
res.writeHead = function() { | ||
if(!runPatches) return writeHead.apply(res, arguments); | ||
res.writeHead = function () { | ||
if (!runPatches) return writeHead.apply(res, arguments); | ||
@@ -147,3 +147,3 @@ var headers = arguments[arguments.length - 1]; | ||
if (res.getHeader('content-length')) res.removeHeader( 'content-length' ); | ||
if (res.getHeader('content-length')) res.removeHeader('content-length'); | ||
@@ -153,4 +153,4 @@ writeHead.apply(res, arguments); | ||
res.end = function(string, encoding) { | ||
if(!runPatches) return end.call(res, string, encoding); | ||
res.end = function (string, encoding) { | ||
if (!runPatches) return end.call(res, string, encoding); | ||
@@ -157,0 +157,0 @@ // If there are remaining bytes, save them as well |
{ | ||
"name": "connect-livereload", | ||
"description": "connect middleware for adding the livereload script to the response", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"author": "Andi Neck <andi.neck@intesso.com>", | ||
@@ -17,5 +17,7 @@ "contributors": [ | ||
"devDependencies": { | ||
"express": "~3.2.2", | ||
"supertest": "~0.15.0", | ||
"mocha": "~1.9.0" | ||
"connect": "^3.3.4", | ||
"express": "~4.11.2", | ||
"mocha": "~2.1.0", | ||
"serve-static": "^1.8.1", | ||
"supertest": "~0.15.0" | ||
}, | ||
@@ -22,0 +24,0 @@ "keywords": [ |
@@ -0,1 +1,2 @@ | ||
connect-livereload | ||
@@ -7,4 +8,9 @@ ================== | ||
[![NPM](https://nodei.co/npm/connect-livereload.png?downloads=true&downloadRank=true)](https://nodei.co/npm-dl/connect-livereload/) | ||
[![Build Status](https://travis-ci.org/intesso/connect-livereload.png)](https://travis-ci.org/intesso/connect-livereload) | ||
[![NPM version](https://badge.fury.io/js/connect-livereload.png)](http://badge.fury.io/js/connect-livereload) | ||
[![Coverage Status](https://coveralls.io/repos/intesso/connect-livereload/badge.svg)](https://coveralls.io/r/intesso/connect-livereload) | ||
install | ||
@@ -11,0 +17,0 @@ ======= |
Sorry, the diff of this file is not supported yet
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
38132
16
153
5