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

watchr

Package Overview
Dependencies
Maintainers
1
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

watchr - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

3

LICENSE.txt
(The MIT License)
Copyright (c) 2011-2012 Benjamin Lupton <b@lupton.cc>
Copyright (c) 2012 Bevry Pty Ltd <us@bevry.me>
Copyright (c) 2011 Benjamin Lupton <b@lupton.cc>

@@ -5,0 +6,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@@ -18,3 +18,3 @@ // Generated by CoffeeScript 1.3.3

path: watchPath,
event: function() {
listener: function() {
var args;

@@ -21,0 +21,0 @@ args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];

@@ -17,3 +17,4 @@ // Generated by CoffeeScript 1.3.3

__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__slice = [].slice;
__slice = [].slice,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

@@ -24,6 +25,6 @@ pathUtil = require('path');

balUtil = require('bal-util');
EventEmitter = require('events').EventEmitter;
balUtil = require('bal-util');
debug = false;

@@ -81,4 +82,4 @@

} else {
fsUtil.stat(config.path, function(err, stat) {
if (watcher.state === 'closed') {
balUtil.stat(config.path, function(err, stat) {
if (watcher.state !== 'pending') {
return;

@@ -124,3 +125,3 @@ }

if (debug) {
console.log("watch event triggered on " + this.path);
console.log("watch event triggered on " + this.path + "\n", args);
}

@@ -140,3 +141,3 @@ isTheSame = function() {

}
return _this.emit('changed', 'unlink', fileFullPath, currentStat, previousStat);
return _this.close('unlink');
} else {

@@ -150,7 +151,7 @@ if (isTheSame()) {

if (isTheSame() === false) {
return fsUtil.readdir(fileFullPath, function(err, newFileRelativePaths) {
return balUtil.readdir(fileFullPath, function(err, newFileRelativePaths) {
if (err) {
throw err;
}
return balUtil.each(newFileRelativePaths, function(newFileRelativePath) {
balUtil.each(newFileRelativePaths, function(newFileRelativePath) {
var newFileFullPath;

@@ -161,3 +162,3 @@ if (_this.children[newFileRelativePath] != null) {

newFileFullPath = pathUtil.join(fileFullPath, newFileRelativePath);
return fsUtil.stat(newFileFullPath, function(err, newFileStat) {
return balUtil.stat(newFileFullPath, function(err, newFileStat) {
if (err) {

@@ -174,2 +175,14 @@ throw err;

});
return balUtil.each(_this.children, function(childFileWatcher, childFileRelativePath) {
var childFileFullPath;
if (__indexOf.call(newFileRelativePaths, childFileRelativePath) >= 0) {
} else {
childFileFullPath = childFileWatcher.path;
if (debug) {
console.log('determined unlink:', childFileRelativePath);
}
return _this.closeChild(childFileRelativePath, 'unlink');
}
});
});

@@ -189,3 +202,3 @@ }

if (fileExists) {
return fsUtil.stat(fileFullPath, function(err, stat) {
return balUtil.stat(fileFullPath, function(err, stat) {
if (err) {

@@ -205,9 +218,9 @@ throw err;

_Class.prototype.close = function() {
_Class.prototype.close = function(type) {
var childRelativePath, watchr, _ref;
if (this.state === 'closed') {
if (this.state !== 'active') {
return this;
}
if (debug) {
console.log("close: " + this.path);
console.log("close: " + this.path + " ", new Error('trace').stack);
}

@@ -218,11 +231,14 @@ _ref = this.children;

watchr = _ref[childRelativePath];
this.closeChild(childRelativePath);
this.closeChild(childRelativePath, type);
}
if (this.state !== 'closed') {
if (this.method === 'watchFile') {
fsUtil.unwatchFile(this.path);
} else if (this.method === 'watch' && this.fswatcher) {
this.fswatcher.close();
this.fswatcher = null;
}
if (this.method === 'watchFile') {
fsUtil.unwatchFile(this.path);
} else if (this.method === 'watch' && this.fswatcher) {
this.fswatcher.close();
this.fswatcher = null;
}
if (type === 'unlink') {
this.emit('changed', 'unlink', this.path, null, this.stat);
this.state = 'unlink';
} else {
this.state = 'closed';

@@ -236,7 +252,7 @@ }

_Class.prototype.closeChild = function(fileRelativePath) {
_Class.prototype.closeChild = function(fileRelativePath, type) {
var watcher;
watcher = this.children[fileRelativePath];
if (watcher) {
watcher.close();
watcher.close(type);
delete this.children[fileRelativePath];

@@ -256,2 +272,5 @@ }

args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (args.length > 3 && args[0] === 'changed' && args[1] === 'unlink' && args[2] === fileFullPath) {
this.closeChild(fileRelativePath, 'unlink');
}
return me.bubble.apply(me, args);

@@ -277,8 +296,8 @@ },

config = this.config;
this.close();
if (debug) {
console.log("watch: " + this.path);
console.log("watch: " + this.path, new Error('trace').stack);
}
this.close();
startWatching = function() {
var tasks;
var tasks, watchFileOpts, _ref, _ref1;
tasks = new balUtil.Group(function(err) {

@@ -307,3 +326,7 @@ return typeof next === "function" ? next(err) : void 0;

try {
fsUtil.watchFile(_this.path, function() {
watchFileOpts = {
persistant: (_ref = config.persistant) != null ? _ref : true,
interval: (_ref1 = config.interval) != null ? _ref1 : 100
};
fsUtil.watchFile(_this.path, watchFileOpts, function() {
var args;

@@ -310,0 +333,0 @@ args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];

{
"name": "watchr",
"version": "2.1.0",
"version": "2.1.1",
"description": "Provides a better and normalised API between Node's 0.4 watchFile and 0.6's fsWatcher",

@@ -33,3 +33,3 @@ "homepage": "https://github.com/bevry/watchr",

"dependencies": {
"bal-util": "1.9.x"
"bal-util": "1.11.x"
},

@@ -36,0 +36,0 @@ "devDependencies": {

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