Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

tail-file

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tail-file - npm Package Compare versions

Comparing version
1.4.10
to
1.4.11
+1
-1
package.json
{
"name": "tail-file",
"version": "1.4.10",
"version": "1.4.11",
"description": "Tail files fast, easy, persistent, fault tolerant and flexible",

@@ -5,0 +5,0 @@ "main": "tail.js",

+50
-22

@@ -526,3 +526,3 @@ 'use strict';

this.watcher.on('change', this.checkDir.bind(this) );
this.watcher.on('error', this.onError.bind(this) );
this.watcher.on('error', this.checkDirError.bind(this) );
}

@@ -535,2 +535,7 @@

checkDirError( err ){
debug('watcher', err);
return this.onError( err );
}
checkDir(type, name ){

@@ -556,2 +561,3 @@ debug(`Dir ${type}: ${name}`);

// handle all file and watcher errors
debug('onError', err);
this._stop(); // Do not wait

@@ -576,11 +582,27 @@

stop(){
async stop(){
const self = this;
self.stopping = self.started || self.filename;
if( this.watcher ){
this.watcher.off('change', this.checkDir.bind(this) );
this.watcher.off('error', this.checkDirError.bind(this) );
await new Promise( (resolve,reject) =>{
this.watcher.on('error', err => reject(err) );
this.watcher.on('close', ()=>{
delete this.watcher;
resolve();
});
this.watcher.close();
});
}
if( !self.starting ){
self._stop();
return Promise.resolve();
return true;
}
return new Promise( (resolve,reject) =>{
await new Promise( (resolve,reject) =>{

@@ -607,5 +629,7 @@ function onEvent(){

self.on('ready', onEvent );
self.stopping = self.starting;
debug('stop', self.stopping);
});
self.stopping = null;
return true;
}

@@ -622,23 +646,29 @@

if( this.started ){
//debug(`Stops tail of ${this.started}`);
debug(`Stops tail of ${this.started}`);
}
if( this.watcher ){
//debug('stop watcher');
this.watcher.close();
delete this.watcher;
}
// if( this.watcher ) throw(new Error('can not stop watcher async'));
if( this.fd ){
if( this.fd !== 'init' ){
//debug("Closing fd " + this.fd);
fs.close( this.fd, err =>{
if( err ) debug( "closing " + err );
});
// debug("Closing fd " + this.fd);
try {
fs.closeSync( this.fd );
} catch( err ){
debug( "closing", err );
}
}
delete this.fd;
}
this.pos = 0; // byte pos
this.posLast = 0;
this.posNext = 0;
this.posSkip = 0;
this.txt = '';
this.started = null;
this.reading = false;
this.readable = false;
this.stopping = null;
}

@@ -690,3 +720,3 @@

// debug("Starts reading at " + this.pos);
// debug("Starts reading at " + this.pos, this.fd);
if(!this.buf) this.buf = Buffer.alloc(this._bufsize);

@@ -701,2 +731,4 @@ fs.read( this.fd, this.buf, 0, this._bufsize, this.pos,

this.reading = false;
debug('readStuff err', err );
if( !this.started || !this.fd || this.stopping ) return;
return this.onLine( err );

@@ -820,8 +852,4 @@ }

if( err ){
debug( err );
self.emit('eof', self.pos);
return;
}
if( self.ino !== stat.ino ){
debug( 'onEndOfFileForTail stat', err );
} else if( self.ino !== stat.ino ){
if( stat.size ){

@@ -828,0 +856,0 @@ debug("Switching over to the new file");

@@ -31,3 +31,3 @@ 'use strict';

after(async()=>{
after(async ()=>{
try{ fs.unlinkSync( filename ) } catch(err){};

@@ -102,6 +102,6 @@ try{ fs.unlinkSync( secondary ) } catch(err){};

after(async()=>{
after(async ()=>{
await t.tail1.stop();
fs.closeSync(t.fd);
fs.closeSync(t.fd2);
fs.closeSync(t.fd);
fs.closeSync(t.fd2);
});

@@ -154,10 +154,11 @@

describe('Missing primary', function(){
const tail1 = new Tail(filename);
let tail1;
before(async ()=>{
before( ()=>{
try{ fs.unlinkSync( filename ) } catch(err){};
try{ fs.unlinkSync( secondary ) } catch(err){};
tail1 = new Tail(filename);
});
after( async ()=> tail1.stop() );
after( ()=> tail1.stop() );

@@ -177,3 +178,3 @@ it('starts in secondary', async function(){

const tail1 = new Tail(filename);
let tail1;

@@ -187,6 +188,7 @@ before( async ()=>{

tail1 = new Tail(filename);
await tail1.startP();
});
after( async ()=> tail1.stop() );
after( ()=> tail1.stop() );

@@ -228,3 +230,3 @@ it("emits line on append", async function(){

const tail1 = new Tail( fname(0) );
let tail1;
const lines = [];

@@ -248,2 +250,4 @@ let fd, rowcnt = 0;

before( async ()=>{
tail1 = new Tail( fname(0) );
function zip(no){

@@ -294,3 +298,3 @@ return new Promise( (resolve,reject)=>{

after(async()=>{
after(async ()=>{
debug('stop tail1');

@@ -352,3 +356,3 @@ tail1.off('line', onLine );

const tail1 = new Tail( fname(0) );
let tail1;
const lines = [];

@@ -366,2 +370,3 @@ let fd, rowcnt = 0, eof;

before( async ()=>{
tail1 = new Tail( fname(0) );
try{ fs.unlinkSync( fname(0) ) } catch(err){};

@@ -384,3 +389,3 @@ fd = await open( fname(1), 'w');

after(async()=>{
after(async ()=>{
debug('stop tail1');

@@ -437,3 +442,3 @@ await tail1.stop().catch(err=>debug('caught'))

const tail1 = new Tail( fname(0) );
let tail1;
const lines = [];

@@ -451,2 +456,3 @@ let fd, rowcnt = 0, eof;

before( async ()=>{
tail1 = new Tail( fname(0) );
fd = await open( fname(1), 'w');

@@ -476,3 +482,3 @@ fs.writeSync(fd, "stuff\n");

after(async()=>{
after(async ()=>{
debug('stop tail1');

@@ -507,3 +513,3 @@ await tail1.stop().catch(err=>debug('caught'))

const tail1 = new Tail( fname(0) );
let tail1;
const lines = [];

@@ -521,2 +527,3 @@ let fd, rowcnt = 0, eof;

before( async ()=>{
tail1 = new Tail( fname(0) );
fd = await open( fname(2), 'w');

@@ -551,3 +558,3 @@ fs.writeSync(fd, "stuff\n");

after(async()=>{
after(async ()=>{
debug('stop tail1');

@@ -584,3 +591,3 @@ await tail1.stop().catch(err=>debug('caught'))

const tail1 = new Tail( filename );
let tail1;
const lines = [];

@@ -596,2 +603,3 @@ let fd, rowcnt = 0;

before( async ()=>{
tail1 = new Tail( filename );

@@ -604,3 +612,3 @@ fd = await open( filename, 'w');

after(async()=>{
after(async ()=>{
debug('stop tail1');

@@ -607,0 +615,0 @@ await tail1.stop();