enhanced-require
Advanced tools
Comparing version 0.4.0-beta6 to 0.4.0-beta9
@@ -38,2 +38,3 @@ var RequireContext = require("./RequireContext"); | ||
this.require.hot.apply = this.root.apply.bind(this.root); | ||
this.require.hot.stop = this.root.stop.bind(this.root); | ||
} | ||
@@ -40,0 +41,0 @@ |
@@ -96,2 +96,11 @@ var fs = require("fs"); | ||
HotRequireRoot.prototype.stop = function() { | ||
if(this._watchDelayTimeout) clearTimeout(this._watchDelayTimeout); | ||
Object.keys(this.resources).forEach(function(res) { | ||
this._disposeResourceLink(this.resources[res]); | ||
delete this.resources[res]; | ||
}, this); | ||
this.options.watch = false; | ||
} | ||
//// protected //// | ||
@@ -135,5 +144,12 @@ | ||
if(this._watchDelayTimeout) clearTimeout(this._watchDelayTimeout); | ||
this._watchDelayTimeout = setTimeout(this._peekWatch.bind(this, function() {}), this.options.watchDelay); | ||
this._watchDelayTimeout = setTimeout(this._peekWatch.bind(this, this._onAutomaticPeekWatchResult.bind(this)), this.options.watchDelay); | ||
} | ||
HotRequireRoot.prototype._onAutomaticPeekWatchResult = function(err, result) { | ||
if(typeof this.options.onAutomaticCheck === "function") { | ||
return this.options.onAutomaticCheck(err, result); | ||
} | ||
if(err) throw err; | ||
} | ||
HotRequireRoot.prototype._peekWatch = function(callback) { | ||
@@ -140,0 +156,0 @@ this.currentChangedResources = {}; |
{ | ||
"name": "enhanced-require", | ||
"version": "0.4.0-beta6", | ||
"version": "0.4.0-beta9", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -5,0 +5,0 @@ "description": "Enhance the require function in node.js with support for loaders which preprocess files and really async require (AMD). Enables Hot Code Replacement.", |
@@ -169,2 +169,3 @@ var should = require("should"); | ||
list.should.be.eql([1, -1, 2, -2, 3]); | ||
req.hot.stop(); | ||
done(); | ||
@@ -211,2 +212,3 @@ }, 100); | ||
list.should.be.eql([1, -1, 2, -2, 3]); | ||
req.hot.stop(); | ||
done(); | ||
@@ -213,0 +215,0 @@ }); |
65656
1835