Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit daff3b8

Browse filesBrowse files
anonrigRafaelGSS
authored andcommitted
fs: update todo message
PR-URL: #45265 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
1 parent e118dd8 commit daff3b8
Copy full SHA for daff3b8

File tree

Expand file treeCollapse file tree

3 files changed

+16
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+16
-11
lines changed
Open diff view settings
Collapse file

‎lib/fs.js‎

Copy file name to clipboardExpand all lines: lib/fs.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2299,7 +2299,7 @@ function watch(filename, options, listener) {
22992299

23002300
let watcher;
23012301

2302-
// TODO(anonrig): Remove this when/if libuv supports it.
2302+
// TODO(anonrig): Remove non-native watcher when/if libuv supports recursive.
23032303
// As of November 2022, libuv does not support recursive file watch on all platforms,
23042304
// e.g. Linux due to the limitations of inotify.
23052305
if (options.recursive && !isOSX && !isWindows) {
Collapse file

‎lib/internal/fs/promises.js‎

Copy file name to clipboardExpand all lines: lib/internal/fs/promises.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ async function* _watch(filename, options = kEmptyObject) {
925925
if (options.recursive != null) {
926926
validateBoolean(options.recursive, 'options.recursive');
927927

928-
// TODO(anonrig): Remove this when/if libuv supports it.
928+
// TODO(anonrig): Remove non-native watcher when/if libuv supports recursive.
929929
// As of November 2022, libuv does not support recursive file watch on all platforms,
930930
// e.g. Linux due to the limitations of inotify.
931931
if (options.recursive && !isOSX && !isWindows) {
Collapse file

‎lib/internal/fs/recursive_watch.js‎

Copy file name to clipboardExpand all lines: lib/internal/fs/recursive_watch.js
+14-9Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ const { getValidatedPath } = require('internal/fs/utils');
2323
const { kFSWatchStart, StatWatcher } = require('internal/fs/watchers');
2424
const { kEmptyObject } = require('internal/util');
2525
const { validateBoolean, validateAbortSignal } = require('internal/validators');
26-
const path = require('path');
26+
const {
27+
basename: pathBasename,
28+
join: pathJoin,
29+
relative: pathRelative,
30+
resolve: pathResolve,
31+
} = require('path');
2732

2833
let internalSync;
2934
let internalPromises;
@@ -45,7 +50,7 @@ async function traverse(dir, files = new SafeMap(), symbolicLinks = new SafeSet(
4550
const subdirectories = [];
4651

4752
for await (const file of filenames) {
48-
const f = path.join(dir, file.name);
53+
const f = pathJoin(dir, file.name);
4954

5055
files.set(f, file);
5156

@@ -67,7 +72,7 @@ class FSWatcher extends EventEmitter {
6772
#closed = false;
6873
#files = new SafeMap();
6974
#symbolicFiles = new SafeSet();
70-
#rootPath = path.resolve();
75+
#rootPath = pathResolve();
7176
#watchingFile = false;
7277

7378
constructor(options = kEmptyObject) {
@@ -140,10 +145,10 @@ class FSWatcher extends EventEmitter {
140145
break;
141146
}
142147

143-
const f = path.join(folder, file.name);
148+
const f = pathJoin(folder, file.name);
144149

145150
if (!this.#files.has(f)) {
146-
this.emit('change', 'rename', path.relative(this.#rootPath, f));
151+
this.emit('change', 'rename', pathRelative(this.#rootPath, f));
147152

148153
if (file.isSymbolicLink()) {
149154
this.#symbolicFiles.add(f);
@@ -186,23 +191,23 @@ class FSWatcher extends EventEmitter {
186191
if (currentStats.birthtimeMs === 0 && previousStats.birthtimeMs !== 0) {
187192
// The file is now deleted
188193
this.#files.delete(file);
189-
this.emit('change', 'rename', path.relative(this.#rootPath, file));
194+
this.emit('change', 'rename', pathRelative(this.#rootPath, file));
190195
this.#unwatchFiles(file);
191196
} else if (file === this.#rootPath && this.#watchingFile) {
192197
// This case will only be triggered when watching a file with fs.watch
193-
this.emit('change', 'change', path.basename(file));
198+
this.emit('change', 'change', pathBasename(file));
194199
} else if (this.#symbolicFiles.has(file)) {
195200
// Stats from watchFile does not return correct value for currentStats.isSymbolicLink()
196201
// Since it is only valid when using fs.lstat(). Therefore, check the existing symbolic files.
197-
this.emit('change', 'rename', path.relative(this.#rootPath, file));
202+
this.emit('change', 'rename', pathRelative(this.#rootPath, file));
198203
} else if (currentStats.isDirectory()) {
199204
this.#watchFolder(file);
200205
}
201206
});
202207
}
203208

204209
[kFSWatchStart](filename) {
205-
filename = path.resolve(getValidatedPath(filename));
210+
filename = pathResolve(getValidatedPath(filename));
206211

207212
try {
208213
const file = lazyLoadFsSync().statSync(filename);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.