hot-reload
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -7,2 +7,3 @@ // third-party dependencies | ||
var directoryWalker = require('directory-walker'); | ||
var pathFilters = require('path-filters'); | ||
@@ -73,8 +74,11 @@ var simpleRegExpReplacements = { | ||
this._uncacheExcludes = []; | ||
this._watchIncludes = {}; | ||
this._watchExcludeFilters = []; | ||
this._watchExcludeFilters = pathFilters.create(); | ||
this._reloadIncludes = []; | ||
this._reloadExcludes = []; | ||
this._specialReloadIncludes = []; | ||
this._specialReloadExcludes = []; | ||
this._specialReloadIncludes = pathFilters.create(); | ||
this._specialReloadExcludes = pathFilters.create(); | ||
this._pending = 0; | ||
@@ -183,62 +187,4 @@ this._reloadDelay = 2000; | ||
HotReloader.prototype._addPathFilters = function(target, filter, recursive, matchResult) { | ||
if (Array.isArray(filter)) { | ||
var filters = filter; | ||
for (var i=0, len=filters.length; i<filters; i++) { | ||
this._addPathFilters(target, filters[i], recursive, matchResult); | ||
} | ||
return; | ||
} | ||
var filterFunc; | ||
if (typeof filter === 'string') { | ||
if (isSimpleRegExp(filter)) { | ||
filterFunc = createSimpleRegExpFilter(filter, matchResult); | ||
} | ||
else { | ||
var path = fs.realpathSync(filter); | ||
if (fs.existsSync(path)) { | ||
var stat = fs.statSync(path); | ||
if (stat.isFile()) { | ||
recursive = false; | ||
} | ||
} | ||
recursive = recursive !== false; | ||
filterFunc = function(testPath) { | ||
var match = recursive ? testPath.startsWith(path) : testPath === path; | ||
return match ? matchResult || true : false; | ||
}; | ||
} | ||
} | ||
else if (filter.constructor === RegExp) { | ||
filterFunc = function(testPath) { | ||
return testPath.test(filter) ? matchResult || true : false; | ||
} | ||
} | ||
else if (typeof filter === 'function') { | ||
if (matchResult) { | ||
filterFunc = function(path) { | ||
var result = filter(path); | ||
return result ? matchResult : false; | ||
} | ||
} | ||
else { | ||
filterFunc = filter; | ||
} | ||
} | ||
else { | ||
throw new Error("Invalid filter: " + filter + " (" + (typeof filter) + ")"); | ||
} | ||
target.push(filterFunc); | ||
return this; | ||
} | ||
HotReloader.prototype.watchExclude = function(filter, recursive) { | ||
this._addPathFilters(this._watchExcludeFilters, filter, recursive); | ||
this._watchExcludeFilters.add(filter, recursive); | ||
return this; | ||
@@ -252,4 +198,3 @@ } | ||
} | ||
this._addPathFilters(this._specialReloadIncludes, filter, recursive, handlerFunc); | ||
this._specialReloadIncludes.add(filter, recursive, handlerFunc); | ||
return this; | ||
@@ -259,3 +204,3 @@ } | ||
HotReloader.prototype.specialReloadExclude = function(filter, recursive) { | ||
this._addPathFilters(this._specialReloadExcludes, filter, recursive); | ||
this._specialReloadExcludes.add(filter, recursive); | ||
return this; | ||
@@ -364,3 +309,3 @@ } | ||
if (this._shouldReloadModule(module.filename)) { | ||
modulesToReload.push(module); | ||
modulesToReload.push(module); | ||
} | ||
@@ -450,3 +395,3 @@ } | ||
else { | ||
handleModified(event, require('path').join(watchInclude.path, filename)); | ||
handleModified(event, require('path').join(watchInclude.path, filename)); | ||
} | ||
@@ -469,3 +414,3 @@ } | ||
var watcher = fs.watch( | ||
fs.realpathSync(path), | ||
fs.realpathSync(path), | ||
createWatcherFunc(watchInclude)); | ||
@@ -472,0 +417,0 @@ |
{ | ||
"name": "hot-reload", | ||
"description": "Triggers reloading of Node.js modules", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"homepage": "https://github.com/philidem/node-hot-reload", | ||
@@ -18,4 +18,5 @@ "authors": [ | ||
"dependencies": { | ||
"directory-walker": "1.2.x" | ||
"directory-walker": "1.2.x", | ||
"path-filters": "1.0.x" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
47758
2
336
+ Addedpath-filters@1.0.x