Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pathwatcher

Package Overview
Dependencies
Maintainers
1
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pathwatcher - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

30

lib/main.js
var binding = require('../build/Release/pathwatcher.node');
var events = require("events");
var events = require('events');
var fs = require('fs');
var util = require('util');

@@ -18,5 +19,3 @@

this.path = path;
this.handle = binding.watch(path);
handleWatchers[this.handle] = this;
this.start();
}

@@ -28,3 +27,19 @@

if (event == 'rename') {
this.path = path;
var self = this;
// Detect atomic write.
this.close();
setTimeout(function() {
fs.stat(self.path, function(err) {
if (err) { // original file is gone it's a rename.
self.path = path;
self.start();
self.trigger('rename', path);
} else { // atomic write.
self.start();
self.trigger('change', path);
}
});
}, 100);
return;
} else if (event == 'delete') {

@@ -37,2 +52,7 @@ this.close();

HandleWatcher.prototype.start = function() {
this.handle = binding.watch(this.path);
handleWatchers[this.handle] = this;
}
HandleWatcher.prototype.closeIfNoListener = function() {

@@ -39,0 +59,0 @@ if (this.listeners('change').length == 0)

2

package.json

@@ -6,3 +6,3 @@ {

"description": "watch events of a file",
"version": "0.1.0",
"version": "0.1.1",
"repository": {

@@ -9,0 +9,0 @@ "type": "git",

watcher = require('./lib/main.js');
var r = watcher.watch('/tmp/', function(event, path) {
var r = watcher.watch('/tmp/test.txt', function(event, path) {
console.log(event, path);

@@ -5,0 +5,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc