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.3.2 to 2.3.3

LICENSE.md

9

History.md
## History
- v2.3.3 January 8, 2013
- Added `outputLog` option
- Added `ignorePaths` option
- Thanks to [Tane Piper](https://github.com/tanepiper) for [issue #24](https://github.com/bevry/watchr/issues/24)
- Now properly ignores hidden files
- Thanks to [Ting-yu (Joseph) Chiang](https://github.com/josephj) for [issue #25](https://github.com/bevry/watchr/issues/25) and [Julien M.](https://github.com/julienma) for [issue #28](https://github.com/bevry/watchr/issues/28)
- Added `Watcher::isIgnoredPath` method
- Added tests for ignored and hidden files
- v2.3.2 January 6, 2013

@@ -4,0 +13,0 @@ - Fixed closing when a child path watcher doesn't exist

110

out/lib/watchr.js

@@ -50,10 +50,26 @@ // Generated by CoffeeScript 1.4.0

_Class.prototype.config = null;
_Class.prototype.config = {
path: null,
outputLog: false,
listener: null,
listeners: null,
stat: null,
ignorePaths: false,
ignoreHiddenFiles: false,
ignoreCommonPatterns: true,
ignoreCustomPatterns: null,
interval: 100,
persistent: true
};
function _Class(config, next) {
this.isIgnoredPath = __bind(this.isIgnoredPath, this);
this.bubbler = __bind(this.bubbler, this);
this.bubble = __bind(this.bubble, this);
this.log = __bind(this.log, this);
this.children = {};
this.config = {};
this.config = balUtil.extend({}, this.config);
if (config.next != null) {

@@ -78,2 +94,5 @@ if (next == null) {

args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (this.config.outputLog) {
console.log.apply(console, args);
}
this.emit.apply(this, ['log'].concat(__slice.call(args)));

@@ -85,12 +104,2 @@ return this;

Setup our Instance
config =
- `path` a single path to watch
- `listener` (optional, detaults to null) single change listener, forwared to @listen
- `listeners` (optional, defaults to null) multiple event listeners, forwarded to @listen
- `stat` (optional, defaults to `null`) a file stat object to use for the path, instead of fetching a new one
- `ignoreHiddenFiles` (optional, defaults to `false`) whether or not to ignored files which filename starts with a `.`
- `ignoreCommonPatterns` (optional, defaults to `true`) whether or not to ignore common undesirable file patterns (e.g. `.svn`, `.git`, `.DS_Store`, `thumbs.db`, etc)
- `ignoreCustomPatterns` (optional, defaults to `null`) any custom ignore patterns that you would also like to ignore along with the common patterns
- `interval` (optional, defaults to `100`) for systems that poll to detect file changes, how often should it poll in millseconds
- `persistent` (optional, defaults to `true`) whether or not we should keep the node process alive for as long as files are still being watched
*/

@@ -100,20 +109,4 @@

_Class.prototype.setup = function(config) {
var _base, _base1, _base2, _base3, _base4, _ref, _ref1, _ref2, _ref3, _ref4;
this.path = config.path;
this.config = config;
if ((_ref = (_base = this.config).ignoreHiddenFiles) == null) {
_base.ignoreHiddenFiles = false;
}
if ((_ref1 = (_base1 = this.config).ignoreCommonPatterns) == null) {
_base1.ignoreCommonPatterns = true;
}
if ((_ref2 = (_base2 = this.config).ignoreCustomPatterns) == null) {
_base2.ignoreCustomPatterns = null;
}
if ((_ref3 = (_base3 = this.config).interval) == null) {
_base3.interval = 100;
}
if ((_ref4 = (_base4 = this.config).persistent) == null) {
_base4.persistent = true;
}
balUtil.extend(this.config, config);
if (this.config.stat) {

@@ -259,17 +252,19 @@ this.stat = this.config.stat;

}
balUtil.each(newFileRelativePaths, function(newFileRelativePath) {
var newFileFullPath;
if (_this.children[newFileRelativePath] != null) {
} else {
newFileFullPath = pathUtil.join(fileFullPath, newFileRelativePath);
return balUtil.stat(newFileFullPath, function(err, newFileStat) {
if (err) {
return _this.emit('error', err);
}
_this.log('debug', 'determined create:', newFileFullPath);
_this.emit('change', 'create', newFileFullPath, newFileStat, null);
return _this.watchChild(newFileFullPath, newFileRelativePath, newFileStat);
});
balUtil.each(newFileRelativePaths, function(childFileRelativePath) {
var childFileFullPath;
if (_this.children[childFileRelativePath] != null) {
return;
}
childFileFullPath = pathUtil.join(fileFullPath, childFileRelativePath);
if (_this.isIgnoredPath(childFileFullPath)) {
return;
}
return balUtil.stat(childFileFullPath, function(err, childFileStat) {
if (err) {
return _this.emit('error', err);
}
_this.log('debug', 'determined create:', childFileFullPath, 'via:', fileFullPath);
_this.emit('change', 'create', childFileFullPath, childFileStat, null);
return _this.watchChild(childFileFullPath, childFileRelativePath, childFileStat);
});
});

@@ -279,8 +274,10 @@ return balUtil.each(_this.children, function(childFileWatcher, childFileRelativePath) {

if (__indexOf.call(newFileRelativePaths, childFileRelativePath) >= 0) {
} else {
childFileFullPath = pathUtil.join(fileFullPath, childFileRelativePath);
_this.log('debug', 'determined delete:', childFileFullPath);
return _this.closeChild(childFileRelativePath, 'deleted');
return;
}
childFileFullPath = pathUtil.join(fileFullPath, childFileRelativePath);
if (_this.isIgnoredPath(childFileFullPath)) {
return;
}
_this.log('debug', 'determined delete:', childFileFullPath, 'via:', fileFullPath);
return _this.closeChild(childFileRelativePath, 'deleted');
});

@@ -377,2 +374,3 @@ });

stat: fileStat,
ignorePaths: config.ignorePaths,
ignoreHiddenFiles: config.ignoreHiddenFiles,

@@ -407,2 +405,17 @@ ignoreCommonPatterns: config.ignoreCommonPatterns,

_Class.prototype.isIgnoredPath = function(path, opts) {
var ignore, _ref, _ref1, _ref2, _ref3;
if (opts == null) {
opts = {};
}
ignore = balUtil.isIgnoredPath(path, {
ignorePaths: (_ref = opts.ignorePaths) != null ? _ref : this.config.ignorePaths,
ignoreHiddenFiles: (_ref1 = opts.ignoreHiddenFiles) != null ? _ref1 : this.config.ignoreHiddenFiles,
ignoreCommonPatterns: (_ref2 = opts.ignoreCommonPatterns) != null ? _ref2 : this.config.ignoreCommonPatterns,
ignoreCustomPatterns: (_ref3 = opts.ignoreCustomPatterns) != null ? _ref3 : this.config.ignoreCustomPatterns
});
this.log('debug', "ignore: " + path + " " + (ignore ? 'yes' : 'no'));
return ignore;
};
/*

@@ -452,2 +465,3 @@ Watch

path: _this.path,
ignorePaths: config.ignorePaths,
ignoreHiddenFiles: config.ignoreHiddenFiles,

@@ -454,0 +468,0 @@ ignoreCommonPatterns: config.ignoreCommonPatterns,

{
"name": "watchr",
"version": "2.3.2",
"version": "2.3.3",
"description": "Better file system watching for Node.js",

@@ -30,10 +30,10 @@ "homepage": "https://github.com/bevry/watchr",

"engines" : {
"node": ">=0.4.0"
"node": ">=0.4"
},
"dependencies": {
"bal-util": "~1.15.2"
"bal-util": "~1.15.4"
},
"devDependencies": {
"coffee-script": "1.4.x",
"joe": "1.1.x"
"coffee-script": "~1.4.0",
"joe": "~1.1.1"
},

@@ -40,0 +40,0 @@ "directories": {

@@ -19,2 +19,3 @@ ## Watchr: better file system watching for Node.js

- `stat` (optional, defaults to `null`) a file stat object to use for the path, instead of fetching a new one
- `ignorePaths` (optional, defaults to `false`) an array of full paths to ignore
- `ignoreHiddenFiles` (optional, defaults to `false`) whether or not to ignored files which filename starts with a `.`

@@ -94,3 +95,3 @@ - `ignoreCommonPatterns` (optional, defaults to `true`) whether or not to ignore common undesirable file patterns (e.g. `.svn`, `.git`, `.DS_Store`, `thumbs.db`, etc)

Licensed under the incredibly [permissive](http://en.wikipedia.org/wiki/Permissive_free_software_licence) [MIT License](http://creativecommons.org/licenses/MIT/)
<br/>Copyright &copy; 2012 [Bevry Pty Ltd](http://bevry.me)
<br/>Copyright &copy; 2012+ [Bevry Pty Ltd](http://bevry.me)
<br/>Copyright &copy; 2011 [Benjamin Lupton](http://balupton.com)
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