Сообщение от Kolyaj
|
Исходники покажите.
|
var EventEmitter = require('events').EventEmitter,
fs = require('fs'),
path = require('path'),
util = require('util');
module.exports = (function () {
function Walker() {
EventEmitter.call(this);
}
util.inherits(Walker, EventEmitter);
Walker.prototype.walk = function (from) {
var root = path.resolve(from),
callback = function (error, tree) {
if (error !== null) {
return this.emit('error', error);
}
tree.forEach(function (leaf) {
var branch = path.join(root, leaf),
callback = function (error, stats) {
if (error !== null) {
return this.emit('error', error);
}
if (stats.isFile()) {
this.emit('file', branch);
} else if (stats.isDirectory()) {
this.walk(branch);
}
}.bind(this);
fs.stat(branch, callback);
}, this);
}.bind(this);
this.emit('directory', root);
fs.readdir(root, callback);
return this;
};
return Walker;
}());