Comparing version 0.3.2 to 0.3.5
{ | ||
"author": "Forward", | ||
"author": "Luca Grulla", | ||
"contributors":["Luca Grulla", "Tom Hall", "Andy Kent"], | ||
"name": "tail", | ||
"description": "tail a file in node", | ||
"version": "0.3.2", | ||
"version": "0.3.5", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/forward/node-tail.git" | ||
"url": "git://github.com/lucagrulla/node-tail.git" | ||
}, | ||
@@ -11,0 +11,0 @@ "main": "tail", |
@@ -58,2 +58,2 @@ #tail | ||
#License | ||
MIT. Please see License file for more details. | ||
MIT. Please see License file for more details. |
34
tail.js
@@ -21,3 +21,3 @@ // Generated by CoffeeScript 1.6.2 | ||
if (this.queue.length >= 1) { | ||
block = this.queue[0]; | ||
block = this.queue.shift(); | ||
if (block.end > block.start) { | ||
@@ -34,3 +34,2 @@ stream = fs.createReadStream(this.filename, { | ||
stream.on('end', function() { | ||
_this.queue.shift(); | ||
if (_this.queue.length >= 1) { | ||
@@ -44,5 +43,2 @@ return _this.internalDispatcher.emit("next"); | ||
_this.buffer += data; | ||
if (_this.pos !== null) { | ||
_this.pos += data.length; | ||
} | ||
parts = _this.buffer.split(_this.separator); | ||
@@ -62,3 +58,4 @@ _this.buffer = parts.pop(); | ||
function Tail(filename, separator, fsWatchOptions) { | ||
var _this = this; | ||
var stats, | ||
_this = this; | ||
@@ -73,8 +70,4 @@ this.filename = filename; | ||
this.isWatching = false; | ||
fs.stat(this.filename, function(err, stats) { | ||
if (err) { | ||
_this.emit('error', err); | ||
} | ||
return _this.pos = stats.size; | ||
}); | ||
stats = fs.statSync(this.filename); | ||
this.pos = stats.size; | ||
this.internalDispatcher.on('next', function() { | ||
@@ -93,5 +86,11 @@ return _this.readBlock(); | ||
this.isWatching = true; | ||
return fs.watchFile(this.filename, this.fsWatchOptions, function(curr, prev) { | ||
return _this.watchFileEvent(curr, prev); | ||
}); | ||
if (fs.watch) { | ||
return this.watcher = fs.watch(this.filename, this.fsWatchOptions, function(e) { | ||
return _this.watchEvent(e); | ||
}); | ||
} else { | ||
return fs.watchFile(this.filename, this.fsWatchOptions, function(curr, prev) { | ||
return _this.watchFileEvent(curr, prev); | ||
}); | ||
} | ||
}; | ||
@@ -107,2 +106,5 @@ | ||
} | ||
if (stats.size < _this.pos) { | ||
_this.pos = stats.size; | ||
} | ||
if (stats.size > _this.pos) { | ||
@@ -113,3 +115,3 @@ _this.queue.push({ | ||
}); | ||
_this.pos += stats.size; | ||
_this.pos = stats.size; | ||
if (_this.queue.length === 1) { | ||
@@ -116,0 +118,0 @@ return _this.internalDispatcher.emit("next"); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5425
131
59