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.4.3 to 2.4.4

123

out/lib/watchr.js

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
var EventEmitter, TaskGroup, Watcher, balUtil, createWatcher, eachr, extendr, fsUtil, pathUtil, safefs, typeChecker, watch, watchers, watchersTotal,

@@ -74,3 +74,4 @@ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },

ignoreCommonPatterns: true,
ignoreCustomPatterns: null
ignoreCustomPatterns: null,
followLinks: true
};

@@ -82,4 +83,6 @@

this.bubble = __bind(this.bubble, this);
this.fileStat = __bind(this.fileStat, this);
this.isIgnoredPath = __bind(this.isIgnoredPath, this);
this.log = __bind(this.log, this); this.children = {};
this.log = __bind(this.log, this);
this.children = {};
this.config = extendr.extend({}, this.config);

@@ -104,5 +107,4 @@ this.config.preferredMethods = ['watch', 'watchFile'];

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

@@ -116,3 +118,2 @@ }

var ignore, _ref, _ref1, _ref2, _ref3;
if (opts == null) {

@@ -131,2 +132,10 @@ opts = {};

_Class.prototype.fileStat = function(path, callback) {
if (this.config.followLinks) {
return safefs.stat(path, callback);
} else {
return safefs.lstat(path, callback);
}
};
/*

@@ -161,3 +170,2 @@ Setup our Instance

var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];

@@ -170,6 +178,4 @@ this.emit.apply(this, args);

var _this = this;
return function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];

@@ -193,3 +199,2 @@ return _this.bubble.apply(_this, [eventName].concat(__slice.call(args)));

var listenerArray, listeners, _i, _j, _len, _len1;
if (listener == null) {

@@ -239,4 +244,3 @@ listeners = eventName;

_Class.prototype.emitSafe = function() {
var args, config, me, thisEvent, _ref;
var args, config, me, thisEvent;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];

@@ -253,3 +257,3 @@ me = this;

}, config.duplicateDelay);
if ((_ref = this.cachedEvents) == null) {
if (this.cachedEvents == null) {
this.cachedEvents = [];

@@ -273,14 +277,20 @@ }

Things to note:
- watchFile:
- currentStat still exists even for deleted/renamed files
- for deleted and updated files, it will fire on the file
- for created files, it will fire on the directory
- fsWatcher:
- eventName is either 'change' or 'rename', this value cannot be trusted
- currentStat still exists even for deleted/renamed files
- previousStat is accurate, however we already have this
- for deleted and changed files, it will fire on the file
- for new files, it will fire on the directory
- watchFile method
- Arguments
- currentStat - the updated stat of the changed file
- Exists even for deleted/renamed files
- previousStat - the last old stat of the changed file
- Is accurate, however we already have this
- For renamed files, it will will fire on the directory and the file
- watch method
- Arguments
- eventName - either 'rename' or 'change'
- THIS VALUE IS ALWAYS UNRELIABLE AND CANNOT BE TRUSTED
- filename - child path of the file that was triggered
- This value can also be unrealiable at times
- Both methods
- For deleted and changed files, it will fire on the file
- For new files, it will fire on the directory
Arguments for our change listener will be:
Output arguments for your emitted event will be:
- for updated files the arguments will be: `'update', fullPath, currentStat, previousStat`

@@ -297,5 +307,4 @@ - for created files the arguments will be: `'create', fullPath, currentStat, null`

_Class.prototype.listener = function() {
var args, currentStat, determineTheChange, fileExists, fileFullPath, isTheSame, me, previousStat,
var args, currentStat, currentStatArgument, determineTheChange, eventNameArgument, fileExists, fileFullPath, filenameArgument, isTheSame, me, method, previousStat, previousStatArgument,
_this = this;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];

@@ -308,12 +317,30 @@ me = this;

this.log('debug', "watch event triggered on " + this.path + ":", args);
if (args[0] === 'change' && this.children[args[1]]) {
return (function() {
var childFileRelativePath, childFileWatcher;
method = null;
eventNameArgument = null;
currentStatArgument = null;
previousStatArgument = null;
filenameArgument = null;
if (typeChecker.isString(args[0])) {
method = 'watch';
eventNameArgument = args[0];
filenameArgument = args[1];
} else {
currentStatArgument = args[0];
previousStatArgument = args[1];
}
/*
# Don't trust the watch method AT ALL
##
# Can we trust the original event handlers?
# We only trust the change event and if we already know about the file it is reporting
# Otherwise chances are something else has changed in the directory than just the file being reported
if eventNameArgument is 'change' and @children[filenameArgument]
return (=>
childFileRelativePath = filenameArgument
childFileWatcher = @children[filenameArgument]
@log('debug', 'forwarding initial change detection to child:', childFileRelativePath, 'via:', fileFullPath)
childFileWatcher.listener('change', '.')
)()
*/
childFileRelativePath = args[1];
childFileWatcher = _this.children[args[1]];
_this.log('debug', 'forwarding initial change detection to child:', childFileRelativePath, 'via:', fileFullPath);
return childFileWatcher.listener('change', '.');
})();
}
isTheSame = function() {

@@ -341,3 +368,3 @@ if ((currentStat != null) && (previousStat != null)) {

}
if (typeChecker.isString(args[0]) && args[1] === null) {
if (method === 'watch') {
eachr(_this.children, function(childFileWatcher, childFileRelativePath) {

@@ -356,3 +383,2 @@ if (__indexOf.call(newFileRelativePaths, childFileRelativePath) < 0) {

var childFileFullPath;
if (__indexOf.call(newFileRelativePaths, childFileRelativePath) >= 0) {

@@ -371,3 +397,2 @@ return;

var childFileFullPath;
if (_this.children[childFileRelativePath] != null) {

@@ -382,3 +407,3 @@ return;

}
return safefs.stat(childFileFullPath, function(err, childFileStat) {
return me.fileStat(childFileFullPath, function(err, childFileStat) {
if (err) {

@@ -408,3 +433,3 @@ return;

if (fileExists) {
return safefs.stat(fileFullPath, function(err, stat) {
return me.fileStat(fileFullPath, function(err, stat) {
if (err) {

@@ -434,3 +459,2 @@ return _this.emit('error', err);

var childRelativePath, _ref;
if (this.state !== 'active') {

@@ -470,3 +494,2 @@ return this;

var watcher;
if (this.children[fileRelativePath] != null) {

@@ -493,3 +516,2 @@ watcher = this.children[fileRelativePath];

var config, me, _base, _name;
me = this;

@@ -504,3 +526,2 @@ config = this.config;

var args, changeType, path;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];

@@ -524,3 +545,4 @@ changeType = args[0], path = args[1];

ignoreCommonPatterns: config.ignoreCommonPatterns,
ignoreCustomPatterns: config.ignoreCustomPatterns
ignoreCustomPatterns: config.ignoreCustomPatterns,
followLinks: config.followLinks
}));

@@ -538,3 +560,2 @@ return me.children[opts.relativePath];

var config, me;
me = this;

@@ -552,3 +573,2 @@ config = this.config;

var watching;
watching = !err;

@@ -583,3 +603,2 @@ return next(err, watching);

var complete, config, me, methodOne, methodTwo, methods;
me = this;

@@ -591,3 +610,2 @@ config = this.config;

var err;
if (fsUtil.watch == null) {

@@ -607,3 +625,2 @@ return next(null, false);

var err, watchFileOpts;
if (fsUtil.watchFile == null) {

@@ -671,7 +688,6 @@ return next(null, false);

_this = this;
me = this;
config = this.config;
if ((this.stat != null) === false) {
safefs.stat(config.path, function(err, stat) {
me.fileStat(config.path, function(err, stat) {
if (err) {

@@ -738,3 +754,2 @@ return _this.emit('error', err);

var attempt, listener, listeners, path, watcher;
path = opts.path, listener = opts.listener, listeners = opts.listeners;

@@ -794,3 +809,2 @@ if (opts.next != null) {

var paths, result, tasks;
result = [];

@@ -815,3 +829,2 @@ if (opts.next != null) {

var localOpts, watcher;
localOpts = extendr.extend({}, opts);

@@ -818,0 +831,0 @@ localOpts.path = path;

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

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

"dependencies": {
"bal-util": "~2.0.0",
"bal-util": "~2.3.0",
"typechecker": "~2.0.1",
"extendr": "~2.0.1",
"extendr": "~2.1.0",
"eachr": "~2.0.2",
"safefs": "~3.0.1",
"taskgroup": "~3.1.1"
"safefs": "~3.0.3",
"taskgroup": "~3.2.3"
},
"devDependencies": {
"coffee-script": "~1.6.2",
"joe": "~1.2.0",
"joe": "~1.3.0",
"joe-reporter-console": "~1.2.1"

@@ -45,0 +45,0 @@ },

@@ -31,2 +31,3 @@ # Watchr &mdash; better file system watching for Node.js

- `ignoreCustomPatterns` (optional, defaults to `null`) any custom ignore patterns that you would also like to ignore along with the common patterns
- `followLinks` (optional, defaults to `true`) follow symlinks, i.e. use stat rather than lstat

@@ -37,2 +38,3 @@ The following events are available to your via the listeners:

- `error` for gracefully listening to error events, receives the arguments `err`
- you should always have an error listener, otherwise node.js's behavior is to throw the error and possibly crash your application, see [#40](https://github.com/bevry/watchr/issues/40)
- `watching` for when watching of the path has completed, receives the arguments `err, isWatching`

@@ -100,16 +102,32 @@ - `change` for listening to change events, receives the arguments `changeType, fullPath, currentStat, previousStat`, received arguments will be:

## Known Issues
- [Text Editor swap files on saving can throw it off.](https://github.com/bevry/watchr/issues/33)
- We're working on it. Workaround for the meantime:
- For Users:
- TextMate: Turn off atomic saves. [Guide.](http://manual.macromates.com/en/saving_files.html)
- Sublime Text 3: Add `"atomic_saves": false` to your user preferences
- VIM: Disable the `set noswapfile` option and enable the `set nobackup` option
- For Watchr implementations:
- Set `preferredMethods` to `['watchFile','watch']` that will use the old polling mechanism (slower, but handles this use case)
- [`ENOENT` errors are emitted when dead links a broken symlink is encountered](https://github.com/bevry/watchr/issues/42)
- We're working on it. No known workaround.
## Support
Support can be found in the [GitHub Issue Tracker](https://github.com/bevry/watchr/issues)
## History
You can discover the history inside the [History.md](https://github.com/bevry/watchr/blob/master/History.md#files) file
## License
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; 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