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

globwatcher

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

globwatcher - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

Changelog.md

43

lib/globwatcher/filewatcher.js
"use strict";
var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

@@ -18,2 +20,3 @@ var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };

var options_in = arguments[0] === undefined ? {} : arguments[0];
_classCallCheck(this, FileWatcher);

@@ -39,3 +42,3 @@

_prototypeProperties(FileWatcher, null, {
_createClass(FileWatcher, {
close: {

@@ -48,5 +51,3 @@ value: function close() {

}
},
writable: true,
configurable: true
}
},

@@ -56,4 +57,6 @@ watch: {

var _this = this;
var mtime = arguments[1] === undefined ? null : arguments[1];
var size = arguments[2] === undefined ? null : arguments[2];
filename = path.resolve(filename);

@@ -71,5 +74,3 @@ var watch = this.watches[filename];

return watch;
},
writable: true,
configurable: true
}
},

@@ -80,5 +81,3 @@ unwatch: {

delete this.watches[filename];
},
writable: true,
configurable: true
}
},

@@ -88,5 +87,3 @@ watchFor: {

return this.watches[path.resolve(filename)];
},
writable: true,
configurable: true
}
},

@@ -98,4 +95,6 @@ check: {

// returns a promise that will be fulfilled when this new scan is finished.
value: function check() {
var _this = this;
this.ongoing = (this.ongoing || Promise.resolve()).then(function () {

@@ -114,5 +113,3 @@ var watches = Object.keys(_this.watches).map(function (key) {

return this.ongoing;
},
writable: true,
configurable: true
}
}

@@ -128,2 +125,3 @@ });

_get(Object.getPrototypeOf(Watch.prototype), "constructor", this).call(this);
this.filename = filename;

@@ -145,6 +143,7 @@ this.mtime = mtime;

_prototypeProperties(Watch, null, {
_createClass(Watch, {
check: {
value: function check() {
var _this = this;
return Promise.promisify(fs.stat)(this.filename)["catch"](function (error) {

@@ -164,5 +163,3 @@ return null;

});
},
writable: true,
configurable: true
}
}

@@ -174,7 +171,5 @@ });

exports.FileWatcher = FileWatcher;
exports.FileWatcher = FileWatcher;
// nevermind.
//# sourceMappingURL=filewatcher.js.map

@@ -5,5 +5,7 @@ "use strict";

var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

@@ -47,3 +49,2 @@ var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };

// sometimes helpful for my own debugging.

@@ -58,6 +59,6 @@ function debugWithTimestamp(message) {

// map (absolute) folder names, which are being folder-level watched, to a
// set of (absolute) filenames in that folder that are being file-level
// watched.
var WatchMap = (function () {

@@ -71,9 +72,7 @@ function WatchMap() {

_prototypeProperties(WatchMap, null, {
_createClass(WatchMap, {
clear: {
value: function clear() {
this.map = {};
},
writable: true,
configurable: true
}
},

@@ -83,5 +82,3 @@ watchFolder: {

if (this.map[folderName] == undefined) this.map[folderName] = {};
},
writable: true,
configurable: true
}
},

@@ -91,5 +88,3 @@ unwatchFolder: {

delete this.map[folderName];
},
writable: true,
configurable: true
}
},

@@ -100,5 +95,3 @@ watchFile: {

this.map[parent][filename] = true;
},
writable: true,
configurable: true
}
},

@@ -108,5 +101,3 @@ unwatchFile: {

delete this.map[parent][filename];
},
writable: true,
configurable: true
}
},

@@ -116,5 +107,3 @@ getFolders: {

return Object.keys(this.map);
},
writable: true,
configurable: true
}
},

@@ -124,5 +113,3 @@ getFilenames: {

return Object.keys(this.map[folderName] || {});
},
writable: true,
configurable: true
}
},

@@ -132,2 +119,3 @@ getAllFilenames: {

var _this = this;
var rv = [];

@@ -138,5 +126,3 @@ this.getFolders().forEach(function (folder) {

return rv;
},
writable: true,
configurable: true
}
},

@@ -148,5 +134,3 @@ getNestedFolders: {

});
},
writable: true,
configurable: true
}
},

@@ -156,5 +140,3 @@ watchingFolder: {

return this.map[folderName] != undefined;
},
writable: true,
configurable: true
}
},

@@ -165,5 +147,3 @@ watchingFile: {

return this.map[parent] != null && this.map[parent][filename] != null;
},
writable: true,
configurable: true
}
},

@@ -173,2 +153,3 @@ toDebug: {

var _this = this;
var out = [];

@@ -182,5 +163,3 @@ Object.keys(this.map).sort().forEach(function (folder) {

return out.join("\n") + "\n";
},
writable: true,
configurable: true
}
}

@@ -192,5 +171,2 @@ });

function globwatcher(pattern, options) {

@@ -202,8 +178,9 @@ return new GlobWatcher(pattern, options);

var GlobWatcher = (function (_events$EventEmitter) {
function GlobWatcher(patterns) {
var options = arguments[1] === undefined ? {} : arguments[1];
_classCallCheck(this, GlobWatcher);
_get(Object.getPrototypeOf(GlobWatcher.prototype), "constructor", this).call(this);
this.closed = false;

@@ -234,4 +211,3 @@ this.cwd = options.cwd || process.cwd();

} else {
var _ref;
(_ref = this).add.apply(_ref, _toConsumableArray(patterns));
this.add.apply(this, _toConsumableArray(patterns));
}

@@ -242,6 +218,7 @@ }

_prototypeProperties(GlobWatcher, null, {
_createClass(GlobWatcher, {
add: {
value: function add() {
var _this = this;
for (var _len = arguments.length, patterns = Array(_len), _key = 0; _key < _len; _key++) {

@@ -269,5 +246,3 @@ patterns[_key] = arguments[_key];

});
},
writable: true,
configurable: true
}
},

@@ -282,5 +257,3 @@ close: {

this.debug("/close");
},
writable: true,
configurable: true
}
},

@@ -290,4 +263,6 @@ check: {

// scan every covered folder again to see if there were any changes.
value: function check() {
var _this = this;
this.debug("-> check");

@@ -300,5 +275,3 @@ var folders = Object.keys(this.watchers).map(function (folderName) {

});
},
writable: true,
configurable: true
}
},

@@ -308,7 +281,6 @@ currentSet: {

// what files exist *right now* that match the watches?
value: function currentSet() {
return this.watchMap.getAllFilenames();
},
writable: true,
configurable: true
}
},

@@ -318,4 +290,6 @@ snapshot: {

// filename -> { mtime size }
value: function snapshot() {
var _this = this;
var state = {};

@@ -327,14 +301,13 @@ this.watchMap.getAllFilenames().forEach(function (filename) {

return state;
},
writable: true,
configurable: true
}
},
restoreFrom: {
// ----- internals:
// restore from a { filename -> { mtime size } } snapshot.
value: function restoreFrom(state, patterns) {
var _this = this;
this.addPatterns(patterns);

@@ -360,5 +333,3 @@ Object.keys(state).forEach(function (filename) {

});
},
writable: true,
configurable: true
}
},

@@ -368,2 +339,3 @@ addPatterns: {

var _this = this;
patterns.forEach(function (p) {

@@ -382,5 +354,3 @@ p = _this.absolutePath(p);

});
},
writable: true,
configurable: true
}
},

@@ -391,2 +361,3 @@ watchPrefix: {

// in case the pattern represents a folder that doesn't exist yet.
value: function watchPrefix(minimatchSet) {

@@ -407,5 +378,3 @@ var index = 0;

}
},
writable: true,
configurable: true
}
},

@@ -415,14 +384,10 @@ absolutePath: {

return p[0] == "/" ? p : path.join(this.cwd, p);
},
writable: true,
configurable: true
}
},
isMatch: {
value: function isMatch(filename) {
return _.any(this.patterns, function (p) {
return _.some(this.patterns, function (p) {
return minimatch(filename, p, { nonegate: true });
});
},
writable: true,
configurable: true
}
},

@@ -444,5 +409,3 @@ addWatch: {

}
},
writable: true,
configurable: true
}
},

@@ -452,2 +415,3 @@ stopWatches: {

var _this = this;
_.forIn(this.watchers, function (watcher, x) {

@@ -463,5 +427,3 @@ watcher.close();

this.closed = true;
},
writable: true,
configurable: true
}
},

@@ -471,2 +433,3 @@ startWatches: {

var _this = this;
this.watchMap.getFolders().forEach(function (folderName) {

@@ -479,5 +442,3 @@ _this.watchFolder(folderName);

this.closed = false;
},
writable: true,
configurable: true
}
},

@@ -487,2 +448,3 @@ watchFolder: {

var _this = this;
this.debug("watch: " + folderName);

@@ -499,5 +461,3 @@ try {

} catch (error) {}
},
writable: true,
configurable: true
}
},

@@ -507,2 +467,3 @@ scanQueue: {

var _this = this;
var folders = Object.keys(this.checkQueue);

@@ -513,5 +474,3 @@ this.checkQueue = {};

});
},
writable: true,
configurable: true
}
},

@@ -521,4 +480,6 @@ watchFile: {

var _this = this;
var mtime = arguments[1] === undefined ? null : arguments[1];
var size = arguments[2] === undefined ? null : arguments[2];
this.debug("watchFile: " + filename);

@@ -530,5 +491,3 @@ // FIXME @persistent @interval

});
},
writable: true,
configurable: true
}
},

@@ -538,2 +497,3 @@ folderChanged: {

var _this = this;
// keep a scoreboard so we can avoid calling readdir() on a folder while

@@ -590,5 +550,3 @@ // we're literally in the middle of a readdir() on that folder already.

});
},
writable: true,
configurable: true
}
},

@@ -605,5 +563,3 @@ fileDeleted: {

this.emit("deleted", filename);
},
writable: true,
configurable: true
}
},

@@ -613,2 +569,3 @@ folderDeleted: {

var _this = this;
// this is trouble, bartman-style, because it may be the only indication

@@ -629,5 +586,3 @@ // we get that an entire subtree is gone. recurse through them, marking

});
},
writable: true,
configurable: true
}
},

@@ -643,5 +598,3 @@ fileAdded: {

return Promise.resolve();
},
writable: true,
configurable: true
}
},

@@ -658,5 +611,3 @@ folderAdded: {

return this.folderChanged(folderName);
},
writable: true,
configurable: true
}
},

@@ -666,11 +617,10 @@ folderIsInteresting: {

// does this folder match the prefix for an existing watch-pattern?
value: function folderIsInteresting(folderName) {
var folderSegments = folderName.split("/");
folderSegments = folderSegments.slice(0, folderSegments.length - 1);
return _.any(this.minimatchSets, function (set) {
return _.some(this.minimatchSets, function (set) {
return folderMatchesMinimatchPrefix(folderSegments, set);
});
},
writable: true,
configurable: true
}
}

@@ -683,4 +633,6 @@ });

// don't worry about it.
// never mind.
// file vanished before we could stat it!
//# sourceMappingURL=globwatcher.js.map
{
"name": "globwatcher",
"version": "1.4.0",
"version": "1.4.1",
"description": "watch a set of files for changes (including create/delete) by glob patterns",

@@ -21,5 +21,5 @@ "keywords": [

"scripts": {
"prepublish": "6to5 --source-maps --out-dir lib src && 6to5 --source-maps --out-dir test/lib test/src",
"build": "./node_modules/.bin/plz build",
"testx": "./node_modules/.bin/plz test -v --color",
"clean": "rm -rf lib test/lib",
"distclean": "npm run clean && rm -rf node_modules npm-debug.log",
"prepublish": "babel --source-maps --out-dir lib src && babel --source-maps --out-dir test/lib test/src",
"test": "mocha -R spec --colors test/lib"

@@ -34,7 +34,5 @@ },

"devDependencies": {
"6to5": "*",
"coffee-script": "^1.7",
"babel": "*",
"mocha": "*",
"mocha-sprinkles": "*",
"plz": "^2.0.3",
"shelljs": "*",

@@ -45,5 +43,4 @@ "should": "*",

},
"main": "./lib/globwatcher",
"main": "./lib/globwatcher/globwatcher",
"files": [
"build.plz",
"lib",

@@ -50,0 +47,0 @@ "test"

@@ -47,3 +47,2 @@ "use strict";

describe("FileWatcher", function () {

@@ -50,0 +49,0 @@ it("creates a watch", fixtures(withFileWatcher(function (watcher, folder) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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