@@ -138,13 +138,14 @@ const {
138
138
validateInteger,
139
139
} = require ( 'internal/validators' ) ;
140
140
141
+ const watchers = require ( 'internal/fs/watchers' ) ;
142
+ const ReadFileContext = require ( 'internal/fs/read_file_context' ) ;
143
+
141
144
let truncateWarn = true ;
142
145
let fs ;
143
146
144
147
// Lazy loaded
145
148
let promises = null ;
146
- let watchers ;
147
- let ReadFileContext ;
148
149
let ReadStream ;
149
150
let WriteStream ;
150
151
let rimraf ;
@@ -369,8 +370,6 @@ function checkAborted(signal, callback) {
369
370
function readFile ( path , options , callback ) {
370
371
callback = maybeCallback ( callback || options ) ;
371
372
options = getOptions ( options , { flag : 'r' } ) ;
372
- if ( ! ReadFileContext )
373
- ReadFileContext = require ( 'internal/fs/read_file_context' ) ;
374
373
const context = new ReadFileContext ( callback , options . encoding ) ;
375
374
context . isUserFd = isFd ( path ) ; // File descriptor ownership
376
375
@@ -2234,8 +2233,6 @@ function watch(filename, options, listener) {
2234
2233
if ( options . recursive === undefined ) options . recursive = false ;
2235
2234
if ( options . recursive && ! ( isOSX || isWindows ) )
2236
2235
throw new ERR_FEATURE_UNAVAILABLE_ON_PLATFORM ( 'watch recursively' ) ;
2237
- if ( ! watchers )
2238
- watchers = require ( 'internal/fs/watchers' ) ;
2239
2236
const watcher = new watchers . FSWatcher ( ) ;
2240
2237
watcher [ watchers . kFSWatchStart ] ( filename ,
2241
2238
options . persistent ,
@@ -2301,8 +2298,6 @@ function watchFile(filename, options, listener) {
2301
2298
stat = statWatchers . get ( filename ) ;
2302
2299
2303
2300
if ( stat === undefined ) {
2304
- if ( ! watchers )
2305
- watchers = require ( 'internal/fs/watchers' ) ;
2306
2301
stat = new watchers . StatWatcher ( options . bigint ) ;
2307
2302
stat [ watchers . kFSStatWatcherStart ] ( filename ,
2308
2303
options . persistent , options . interval ) ;
0 commit comments