Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

...

  • Loading branch information...
commit 36d3f5e160cbafe564f1615ef62f9c30886e73dd 1 parent d63fb23
@ry ry authored
Showing with 10 additions and 17 deletions.
  1. +9 −15 lib/module.js
  2. +1 −2  src/node.js
View
24 lib/module.js
@@ -213,14 +213,14 @@ Module._load = function(request, parent, isMain) {
if (module.timeout) return;
module.timeout = setTimeout(function() {
- console.error(module.filename + ': change detected. reloading.');
+ debug(module.filename + ': change detected. reloading.');
module.reload(function() {
- console.error(module.filename + ': done reloading.');
+ debug(module.filename + ': done reloading.');
});
module.timeout = null;
- }, 1000);
+ }, 200);
});
}
@@ -251,31 +251,25 @@ Module._resolveFilename = function(request, parent) {
Module.prototype.reload = function(cb) {
var self = this;
- debugger;
- //var newSource = require('fs').readFileSync(this.filename, 'utf8');
- console.log("DONE");
- //console.log(newSource);
-
require('fs').readFile(this.filename, 'utf8', function(err, newSource) {
if (err) throw err;
- console.log(arguments);
var script = Debug.findScript(self.compiledWrapper);
+ var scripts = Debug.scripts();
+
+ var wrappedNewSource = Module.wrap(newSource)
/*
- console.log("old source");
- console.log(script.source);
console.log("new source");
console.log(newSource);
*/
- var changeLog = new Array();
- var rv = Debug.LiveEdit.SetScriptSource(script, newSource, false, changeLog);
+ var changeLog = [];
+ var rv = Debug.LiveEdit.SetScriptSource(script, wrappedNewSource, false, changeLog);
+
- console.log("rv ", rv);
- console.log("change log", changeLog);
if (cb) cb(changeLog);
});
};
View
3  src/node.js
@@ -410,14 +410,13 @@
}
NativeModule.wrap = function(script) {
- this.functionid = ++NativeModule.functionid;
return NativeModule.wrapper[0] +
script +
NativeModule.wrapper[1];
};
NativeModule.wrapper = [
- '(function __f(exports, require, module, __filename, __dirname) { ',
+ '(function (exports, require, module, __filename, __dirname) { ',
'\n});'
];
Please sign in to comment.
Something went wrong with that request. Please try again.