2015-02-09 updates

[react-packager] Update other instances of projectRoot to projectRoots | Amjad Masad
[react-packager] Debug page | Amjad Masad
This commit is contained in:
Amjad Masad
2015-02-11 16:37:51 -08:00
parent 3e59937fa9
commit 5aa5e7a875
8 changed files with 113 additions and 21 deletions

View File

@@ -7,6 +7,7 @@ var docblock = require('./docblock');
var path = require('path');
var isAbsolutePath = require('absolute-path');
var debug = require('debug')('DependecyGraph');
var util = require('util');
var readFile = q.nfbind(fs.readFile);
var readDir = q.nfbind(fs.readdir);
@@ -22,6 +23,7 @@ function DependecyGraph(options) {
this._packageByRoot = Object.create(null);
this._packagesById = Object.create(null);
this._moduleById = Object.create(null);
this._debugUpdateEvents = [];
this._fileWatcher = options.fileWatcher;
// Kick off the search process to precompute the dependency graph.
@@ -196,16 +198,20 @@ DependecyGraph.prototype._search = function() {
return readDir(dir)
.then(function(files){
return q.all(files.map(function(filePath) {
return realpath(path.join(dir, filePath));
return realpath(path.join(dir, filePath)).catch(handleBrokenLink);
}));
})
.then(function(filePaths) {
filePaths = filePaths.filter(function(filePath) {
if (filePath == null) {
return false
}
return !self._ignoreFilePath(filePath);
});
var statsP = filePaths.map(function(filePath) {
return lstat(filePath);
return lstat(filePath).catch(handleBrokenLink);
});
return [
@@ -397,6 +403,8 @@ DependecyGraph.prototype._processFileChange = function(eventType, filePath, root
return;
}
this._debugUpdateEvents.push({event: eventType, path: filePath});
if (eventType === 'delete') {
var module = this._graph[absPath];
if (module == null) {
@@ -412,6 +420,13 @@ DependecyGraph.prototype._processFileChange = function(eventType, filePath, root
}
};
DependecyGraph.prototype.getDebugInfo = function() {
return '<h1>FileWatcher Update Events</h1>' +
'<pre>' + util.inspect(this._debugUpdateEvents) + '</pre>' +
'<h1> Graph dump </h1>' +
'<pre>' + util.inspect(this._graph) + '</pre>';
};
/**
* Searches all roots for the file and returns the first one that has file of the same path.
*/
@@ -471,4 +486,9 @@ function withExtJs(file) {
}
}
function handleBrokenLink(e) {
debug('WARNING: error stating, possibly broken symlink', e.message);
return q();
}
module.exports = DependecyGraph;

View File

@@ -119,8 +119,13 @@ HasteDependencyResolver.prototype.wrapModule = function(module, code) {
});
};
HasteDependencyResolver.prototype.end = function() {
return this._fileWatcher.end();
};
HasteDependencyResolver.prototype.getDebugInfo = function() {
return this._depGraph.getDebugInfo();
};
module.exports = HasteDependencyResolver;