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

watchpack

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

watchpack - npm Package Compare versions

Comparing version 2.0.0-beta.11 to 2.0.0-beta.12

147

lib/DirectoryWatcher.js

@@ -8,3 +8,2 @@ /*

const EventEmitter = require("events").EventEmitter;
const async = require("neo-async");
const fs = require("graceful-fs");

@@ -28,2 +27,10 @@ const path = require("path");

function needCalls(times, callback) {
return function() {
if (--times === 0) {
return callback();
}
};
}
class Watcher extends EventEmitter {

@@ -176,2 +183,10 @@ constructor(directoryWatcher, filePath, startTime) {

accuracy = 0;
if (old && old.timestamp === mtime && mtime + FS_ACCURACY < now - 1000) {
// We are sure that mtime is untouched
// This can be caused by some file attribute change
// e. g. when access time has been changed
// but the file content is untouched
return;
}
}

@@ -463,3 +478,3 @@

// On non-osx platforms we don't need this watcher to detect
// directory removal, as a EPERM error indicates that
// directory removal, as an EPERM error indicates that
if ((!IS_OSX || this.polledWatching) && this.parentWatcher) {

@@ -474,3 +489,3 @@ this.parentWatcher.close();

// directory was created so we emit a event
// directory was created so we emit an event
this.forEachWatcher(this.path, w =>

@@ -547,73 +562,71 @@ w.emit("change", this.path, mtime, type)

}
async.forEach(
itemPaths,
(itemPath, callback) => {
fs.lstat(itemPath, (err2, stats) => {
if (this.closed) return;
if (err2) {
if (
err2.code === "ENOENT" ||
err2.code === "EPERM" ||
err2.code === "EBUSY"
) {
this.setMissing(itemPath, initial, "scan (" + err2.code + ")");
} else {
this.onScanError(err2);
const itemFinished = needCalls(itemPaths.size + 1, () => {
if (this.closed) return;
this.initialScan = false;
this.initialScanRemoved = null;
this.initialScanFinished = Date.now();
if (initial) {
const missingWatchers = new Map(this.watchers);
missingWatchers.delete(withoutCase(this.path));
for (const item of itemPaths) {
missingWatchers.delete(withoutCase(item));
}
for (const watchers of missingWatchers.values()) {
for (const watcher of watchers) {
if (watcher.checkStartTime(this.initialScanFinished, false)) {
watcher.emit(
"initial-missing",
"scan (missing in initial scan)"
);
}
callback();
return;
}
if (stats.isFile() || stats.isSymbolicLink()) {
if (stats.mtime) {
ensureFsAccuracy(stats.mtime);
}
this.setFileTime(
}
}
if (this.scanAgain) {
this.scanAgain = false;
this.doScan(this.scanAgainInitial);
} else {
this.scanning = false;
}
});
for (const itemPath of itemPaths) {
fs.lstat(itemPath, (err2, stats) => {
if (this.closed) return;
if (err2) {
if (
err2.code === "ENOENT" ||
err2.code === "EPERM" ||
err2.code === "EBUSY"
) {
this.setMissing(itemPath, initial, "scan (" + err2.code + ")");
} else {
this.onScanError(err2);
}
itemFinished();
return;
}
if (stats.isFile() || stats.isSymbolicLink()) {
if (stats.mtime) {
ensureFsAccuracy(stats.mtime);
}
this.setFileTime(
itemPath,
+stats.mtime || +stats.ctime || 1,
initial,
true,
"scan (file)"
);
} else if (stats.isDirectory()) {
if (!initial || !this.directories.has(itemPath))
this.setDirectory(
itemPath,
+stats.mtime || +stats.ctime || 1,
initial,
true,
"scan (file)"
"scan (dir)"
);
} else if (stats.isDirectory()) {
if (!initial || !this.directories.has(itemPath))
this.setDirectory(
itemPath,
+stats.mtime || +stats.ctime || 1,
initial,
"scan (dir)"
);
}
callback();
});
},
() => {
if (this.closed) return;
this.initialScan = false;
this.initialScanRemoved = null;
this.initialScanFinished = Date.now();
if (initial) {
const missingWatchers = new Map(this.watchers);
missingWatchers.delete(withoutCase(this.path));
for (const item of itemPaths) {
missingWatchers.delete(withoutCase(item));
}
for (const watchers of missingWatchers.values()) {
for (const watcher of watchers) {
if (watcher.checkStartTime(this.initialScanFinished, false)) {
watcher.emit(
"initial-missing",
"scan (missing in initial scan)"
);
}
}
}
}
if (this.scanAgain) {
this.scanAgain = false;
this.doScan(this.scanAgainInitial);
} else {
this.scanning = false;
}
}
);
itemFinished();
});
}
itemFinished();
});

@@ -620,0 +633,0 @@ }

{
"name": "watchpack",
"version": "2.0.0-beta.11",
"version": "2.0.0-beta.12",
"description": "",

@@ -39,8 +39,8 @@ "main": "./lib/watchpack.js",

"rimraf": "^2.6.2",
"should": "^8.3.1"
"should": "^8.3.1",
"write-file-atomic": "^3.0.1"
},
"dependencies": {
"glob-to-regexp": "^0.4.1",
"graceful-fs": "^4.1.2",
"neo-async": "^2.5.0"
"graceful-fs": "^4.1.2"
},

@@ -47,0 +47,0 @@ "engines": {

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