Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependencies #172

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 17 additions & 17 deletions lib/DirectoryWatcher.js
Expand Up @@ -26,7 +26,7 @@ function withoutCase(str) {
}

function needCalls(times, callback) {
return function() {
return function () {
if (--times === 0) {
return callback();
}
Expand Down Expand Up @@ -111,7 +111,7 @@ class DirectoryWatcher extends EventEmitter {
clearTimeout(this.timeout);
this.timeout = undefined;
}
}
},
};
} else {
if (IS_OSX) {
Expand Down Expand Up @@ -147,9 +147,9 @@ class DirectoryWatcher extends EventEmitter {
if (this.nestedWatching) oldDirectory.close();
this.directories.delete(itemPath);

this.forEachWatcher(itemPath, w => w.emit("remove", type));
this.forEachWatcher(itemPath, (w) => w.emit("remove", type));
if (!initial) {
this.forEachWatcher(this.path, w =>
this.forEachWatcher(this.path, (w) =>
w.emit("change", itemPath, null, type, initial)
);
}
Expand All @@ -162,13 +162,13 @@ class DirectoryWatcher extends EventEmitter {
const count = this.filesWithoutCase.get(key) - 1;
if (count <= 0) {
this.filesWithoutCase.delete(key);
this.forEachWatcher(itemPath, w => w.emit("remove", type));
this.forEachWatcher(itemPath, (w) => w.emit("remove", type));
} else {
this.filesWithoutCase.set(key, count);
}

if (!initial) {
this.forEachWatcher(this.path, w =>
this.forEachWatcher(this.path, (w) =>
w.emit("change", itemPath, null, type, initial)
);
}
Expand Down Expand Up @@ -204,7 +204,7 @@ class DirectoryWatcher extends EventEmitter {
this.files.set(filePath, {
safeTime,
accuracy,
timestamp: mtime
timestamp: mtime,
});
this._cachedTimeInfoEntries = undefined;

Expand All @@ -221,15 +221,15 @@ class DirectoryWatcher extends EventEmitter {
this.doScan(false);
}

this.forEachWatcher(filePath, w => {
this.forEachWatcher(filePath, (w) => {
if (!initial || w.checkStartTime(safeTime, initial)) {
w.emit("change", mtime, type);
}
});
} else if (!initial) {
this.forEachWatcher(filePath, w => w.emit("change", mtime, type));
this.forEachWatcher(filePath, (w) => w.emit("change", mtime, type));
}
this.forEachWatcher(this.path, w => {
this.forEachWatcher(this.path, (w) => {
if (!initial || w.checkStartTime(safeTime, initial)) {
w.emit("change", filePath, safeTime, type, initial);
}
Expand All @@ -240,7 +240,7 @@ class DirectoryWatcher extends EventEmitter {
if (this.checkIgnore(directoryPath)) return;
if (directoryPath === this.path) {
if (!initial) {
this.forEachWatcher(this.path, w =>
this.forEachWatcher(this.path, (w) =>
w.emit("change", directoryPath, birthtime, type, initial)
);
}
Expand All @@ -263,12 +263,12 @@ class DirectoryWatcher extends EventEmitter {
safeTime = now;
}

this.forEachWatcher(directoryPath, w => {
this.forEachWatcher(directoryPath, (w) => {
if (!initial || w.checkStartTime(safeTime, false)) {
w.emit("change", birthtime, type);
}
});
this.forEachWatcher(this.path, w => {
this.forEachWatcher(this.path, (w) => {
if (!initial || w.checkStartTime(safeTime, initial)) {
w.emit("change", directoryPath, safeTime, type, initial);
}
Expand All @@ -281,7 +281,7 @@ class DirectoryWatcher extends EventEmitter {
const watcher = this.watcherManager.watchDirectory(directoryPath, 1);
watcher.on("change", (filePath, mtime, type, initial) => {
this._cachedTimeInfoEntries = undefined;
this.forEachWatcher(this.path, w => {
this.forEachWatcher(this.path, (w) => {
if (!initial || w.checkStartTime(mtime, initial)) {
w.emit("change", filePath, mtime, type, initial);
}
Expand Down Expand Up @@ -531,7 +531,7 @@ class DirectoryWatcher extends EventEmitter {
this.doScan(false);

// directory was created so we emit an event
this.forEachWatcher(this.path, w =>
this.forEachWatcher(this.path, (w) =>
w.emit("change", this.path, mtime, type, false)
);
}
Expand Down Expand Up @@ -590,7 +590,7 @@ class DirectoryWatcher extends EventEmitter {
return;
}
const itemPaths = new Set(
items.map(item => path.join(this.path, item.normalize("NFC")))
items.map((item) => path.join(this.path, item.normalize("NFC")))
);
for (const file of this.files.keys()) {
if (!itemPaths.has(file)) {
Expand Down Expand Up @@ -735,7 +735,7 @@ class DirectoryWatcher extends EventEmitter {
}
}
map.set(this.path, {
safeTime
safeTime,
});
} else {
for (const dir of this.directories.keys()) {
Expand Down
2 changes: 1 addition & 1 deletion lib/LinkResolver.js
Expand Up @@ -84,7 +84,7 @@ class LinkResolver {
// the resolve real location
linkResolved[0],
// add the link
realFile
realFile,
]);
}
this.cache.set(file, result);
Expand Down
2 changes: 1 addition & 1 deletion lib/getWatcherManager.js
Expand Up @@ -42,7 +42,7 @@ const watcherManagers = new WeakMap();
* @param {object} options options
* @returns {WatcherManager} the watcher manager
*/
module.exports = options => {
module.exports = (options) => {
const watcherManager = watcherManagers.get(options);
if (watcherManager !== undefined) return watcherManager;
const newWatcherManager = new WatcherManager(options);
Expand Down
4 changes: 2 additions & 2 deletions lib/reducePlan.js
Expand Up @@ -33,7 +33,7 @@ module.exports = (plan, limit) => {
children: undefined,
entries: 1,
active: true,
value
value,
});
}
let currentCount = treeMap.size;
Expand All @@ -49,7 +49,7 @@ module.exports = (plan, limit) => {
children: [node],
entries: node.entries,
active: false,
value: undefined
value: undefined,
};
treeMap.set(parentPath, parent);
node.parent = parent;
Expand Down
18 changes: 8 additions & 10 deletions lib/watchEventSource.js
Expand Up @@ -47,7 +47,7 @@ class DirectWatcher {
w.emit("change", type, filename);
}
});
watcher.on("error", error => {
watcher.on("error", (error) => {
for (const w of this.watchers) {
w.emit("error", error);
}
Expand Down Expand Up @@ -91,16 +91,14 @@ class RecursiveWatcher {
this.watcher = undefined;
try {
const watcher = fs.watch(rootPath, {
recursive: true
recursive: true,
});
this.watcher = watcher;
watcher.on("change", (type, filename) => {
if (!filename) {
if (recursiveWatcherLogging) {
process.stderr.write(
`[watchpack] dispatch ${type} event in recursive watcher (${
this.rootPath
}) to all watchers\n`
`[watchpack] dispatch ${type} event in recursive watcher (${this.rootPath}) to all watchers\n`
);
}
for (const w of this.mapWatcherToPath.keys()) {
Expand All @@ -124,7 +122,7 @@ class RecursiveWatcher {
}
}
});
watcher.on("error", error => {
watcher.on("error", (error) => {
for (const w of this.mapWatcherToPath.keys()) {
w.emit("error", error);
}
Expand Down Expand Up @@ -196,15 +194,15 @@ class Watcher extends EventEmitter {
}
}

const createDirectWatcher = filePath => {
const createDirectWatcher = (filePath) => {
const existing = directWatchers.get(filePath);
if (existing !== undefined) return existing;
const w = new DirectWatcher(filePath);
directWatchers.set(filePath, w);
return w;
};

const createRecursiveWatcher = rootPath => {
const createRecursiveWatcher = (rootPath) => {
const existing = recursiveWatchers.get(rootPath);
if (existing !== undefined) return existing;
const w = new RecursiveWatcher(rootPath);
Expand Down Expand Up @@ -295,7 +293,7 @@ const execute = () => {
}
};

exports.watch = filePath => {
exports.watch = (filePath) => {
const watcher = new Watcher();
// Find an existing watcher
const directWatcher = directWatchers.get(filePath);
Expand All @@ -320,7 +318,7 @@ exports.watch = filePath => {
return watcher;
};

exports.batch = fn => {
exports.batch = (fn) => {
isBatch = true;
try {
fn();
Expand Down
24 changes: 12 additions & 12 deletions lib/watchpack.js
Expand Up @@ -24,16 +24,16 @@ function addWatchersToSet(watchers, set) {
}
}

const stringToRegexp = ignored => {
const stringToRegexp = (ignored) => {
const source = globToRegExp(ignored, { globstar: true, extended: true })
.source;
const matchingStart = source.slice(0, source.length - 1) + "(?:$|\\/)";
return matchingStart;
};

const ignoredToRegexp = ignored => {
const ignoredToRegexp = (ignored) => {
if (Array.isArray(ignored)) {
return new RegExp(ignored.map(i => stringToRegexp(i)).join("|"));
return new RegExp(ignored.map((i) => stringToRegexp(i)).join("|"));
} else if (typeof ignored === "string") {
return new RegExp(stringToRegexp(ignored));
} else if (ignored instanceof RegExp) {
Expand All @@ -45,16 +45,16 @@ const ignoredToRegexp = ignored => {
}
};

const normalizeOptions = options => {
const normalizeOptions = (options) => {
return {
followSymlinks: !!options.followSymlinks,
ignored: ignoredToRegexp(options.ignored),
poll: options.poll
poll: options.poll,
};
};

const normalizeCache = new WeakMap();
const cachedNormalizeOptions = options => {
const cachedNormalizeOptions = (options) => {
const cacheEntry = normalizeCache.get(options);
if (cacheEntry !== undefined) return cacheEntry;
const normalized = normalizeOptions(options);
Expand Down Expand Up @@ -90,7 +90,7 @@ class Watchpack extends EventEmitter {
files = EMPTY_ARRAY,
directories = EMPTY_ARRAY,
missing = EMPTY_ARRAY,
startTime
startTime,
} = arg1);
} else {
files = arg1;
Expand All @@ -103,7 +103,7 @@ class Watchpack extends EventEmitter {
const oldDirectoryWatchers = this.directoryWatchers;
const ignored = this.watcherOptions.ignored;
const filter = ignored
? path => !ignored.test(path.replace(/\\/g, "/"))
? (path) => !ignored.test(path.replace(/\\/g, "/"))
: () => true;
const addToMap = (map, key, item) => {
const list = map.get(key);
Expand Down Expand Up @@ -173,7 +173,7 @@ class Watchpack extends EventEmitter {
const newFileWatchers = new Map();
const newDirectoryWatchers = new Map();
const setupFileWatcher = (watcher, key, files) => {
watcher.on("initial-missing", type => {
watcher.on("initial-missing", (type) => {
for (const file of files) {
if (!missingFiles.has(file)) this._onRemove(file, file, type);
}
Expand All @@ -183,15 +183,15 @@ class Watchpack extends EventEmitter {
this._onChange(file, mtime, file, type);
}
});
watcher.on("remove", type => {
watcher.on("remove", (type) => {
for (const file of files) {
this._onRemove(file, file, type);
}
});
newFileWatchers.set(key, watcher);
};
const setupDirectoryWatcher = (watcher, key, directories) => {
watcher.on("initial-missing", type => {
watcher.on("initial-missing", (type) => {
for (const item of directories) {
this._onRemove(item, item, type);
}
Expand All @@ -201,7 +201,7 @@ class Watchpack extends EventEmitter {
this._onChange(item, mtime, file, type);
}
});
watcher.on("remove", type => {
watcher.on("remove", (type) => {
for (const item of directories) {
this._onRemove(item, item, type);
}
Expand Down
20 changes: 10 additions & 10 deletions package.json
Expand Up @@ -28,20 +28,20 @@
},
"homepage": "https://github.com/webpack/watchpack",
"devDependencies": {
"coveralls": "^3.0.0",
"eslint": "^5.11.1",
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-prettier": "^3.1.0",
"coveralls": "^3.1.0",
"eslint": "^5.16.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"istanbul": "^0.4.3",
"mocha": "^5.0.1",
"prettier": "^1.11.0",
"rimraf": "^2.6.2",
"should": "^8.3.1",
"write-file-atomic": "^3.0.1"
"mocha": "^5.2.0",
"prettier": "2",
"rimraf": "^3.0.2",
"should": "^8.4.0",
"write-file-atomic": "^3.0.3"
},
"dependencies": {
"glob-to-regexp": "^0.4.1",
"graceful-fs": "^4.1.2"
"graceful-fs": "^4.2.4"
},
"engines": {
"node": ">=10.13.0"
Expand Down