Commit 783bd850 authored by Leo Iannacone's avatar Leo Iannacone

Revert "extends Tail in pure coffee"

This reverts commit 21db8f2e.
parent 82558ba5
"use strict"
fs = require("fs") fs = require("fs")
Tail = require("tail").Tail Tail = require("tail").Tail
Tail::watchEvent = (e) ->
_this = this
if e is "change"
fs.stat @filename, (err, stats) ->
if err
_this.emit "error", err
return
_this.pos = stats.size if stats.size < _this.pos
if stats.size > _this.pos
_this.queue.push
start: _this.pos
end: stats.size
class MyTail extends Tail _this.pos = stats.size
_this.internalDispatcher.emit "next" if _this.queue.length is 1
watchEvent: (e) -> else if e is "rename"
if e is 'change'
stats = fs.statSync(@filename)
@pos = stats.size if stats.size < @pos #scenario where texts is not appended but it's actually a w+
if stats.size > @pos
@queue.push({start: @pos, end: stats.size})
@pos = stats.size
@internalDispatcher.emit("next") if @queue.length is 1
else if e is 'rename'
@unwatch()
@emit "error", "File " + @filename + " deleted."
close: () ->
@unwatch() @unwatch()
return _this.emit "error", "File " + @filename + " deleted."
return
Tail::close = ->
@unwatch()
return
module.exports = MyTail module.exports = Tail
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment