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 5d9442a

Browse filesBrowse files
joyeecheungdanielleadams
authored andcommitted
lib: load internal/fs/watchers and internal/fs/read_file_context early
So that they are included in the builtin snapshot PR-URL: #38737 Refs: #35711 Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent a1b0e64 commit 5d9442a
Copy full SHA for 5d9442a

File tree

Expand file treeCollapse file tree

2 files changed

+4
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-8
lines changed
Open diff view settings
Collapse file

‎lib/fs.js‎

Copy file name to clipboardExpand all lines: lib/fs.js
+3-8Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,14 @@ const {
138138
validateInteger,
139139
} = require('internal/validators');
140140

141+
const watchers = require('internal/fs/watchers');
142+
const ReadFileContext = require('internal/fs/read_file_context');
143+
141144
let truncateWarn = true;
142145
let fs;
143146

144147
// Lazy loaded
145148
let promises = null;
146-
let watchers;
147-
let ReadFileContext;
148149
let ReadStream;
149150
let WriteStream;
150151
let rimraf;
@@ -369,8 +370,6 @@ function checkAborted(signal, callback) {
369370
function readFile(path, options, callback) {
370371
callback = maybeCallback(callback || options);
371372
options = getOptions(options, { flag: 'r' });
372-
if (!ReadFileContext)
373-
ReadFileContext = require('internal/fs/read_file_context');
374373
const context = new ReadFileContext(callback, options.encoding);
375374
context.isUserFd = isFd(path); // File descriptor ownership
376375

@@ -2234,8 +2233,6 @@ function watch(filename, options, listener) {
22342233
if (options.recursive === undefined) options.recursive = false;
22352234
if (options.recursive && !(isOSX || isWindows))
22362235
throw new ERR_FEATURE_UNAVAILABLE_ON_PLATFORM('watch recursively');
2237-
if (!watchers)
2238-
watchers = require('internal/fs/watchers');
22392236
const watcher = new watchers.FSWatcher();
22402237
watcher[watchers.kFSWatchStart](filename,
22412238
options.persistent,
@@ -2301,8 +2298,6 @@ function watchFile(filename, options, listener) {
23012298
stat = statWatchers.get(filename);
23022299

23032300
if (stat === undefined) {
2304-
if (!watchers)
2305-
watchers = require('internal/fs/watchers');
23062301
stat = new watchers.StatWatcher(options.bigint);
23072302
stat[watchers.kFSStatWatcherStart](filename,
23082303
options.persistent, options.interval);
Collapse file

‎test/parallel/test-bootstrap-modules.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-bootstrap-modules.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const expectedModules = new Set([
5656
'NativeModule internal/fs/dir',
5757
'NativeModule internal/fs/utils',
5858
'NativeModule internal/fs/promises',
59+
'NativeModule internal/fs/read_file_context',
5960
'NativeModule internal/fs/rimraf',
6061
'NativeModule internal/fs/watchers',
6162
'NativeModule internal/heap_utils',

0 commit comments

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