diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2021-05-20 02:30:47 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2021-05-27 21:46:46 +0800 |
commit | 9e42b4da09989762cb4f08d9703d6c7b9d454d04 (patch) | |
tree | ed5a8ee8ee3f2a9771b13dd980adfcb6d2fa56ce /lib/fs.js | |
parent | 39b0f4fe4c4e663be5529228dcd41d5133468eed (diff) | |
download | node-new-9e42b4da09989762cb4f08d9703d6c7b9d454d04.tar.gz |
lib: load internal/fs/watchers and internal/fs/read_file_context early
So that they are included in the builtin snapshot
PR-URL: https://github.com/nodejs/node/pull/38737
Refs: https://github.com/nodejs/node/issues/35711
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'lib/fs.js')
-rw-r--r-- | lib/fs.js | 11 |
1 files changed, 3 insertions, 8 deletions
@@ -138,13 +138,14 @@ const { validateInteger, } = require('internal/validators'); +const watchers = require('internal/fs/watchers'); +const ReadFileContext = require('internal/fs/read_file_context'); + let truncateWarn = true; let fs; // Lazy loaded let promises = null; -let watchers; -let ReadFileContext; let ReadStream; let WriteStream; let rimraf; @@ -369,8 +370,6 @@ function checkAborted(signal, callback) { function readFile(path, options, callback) { callback = maybeCallback(callback || options); options = getOptions(options, { flag: 'r' }); - if (!ReadFileContext) - ReadFileContext = require('internal/fs/read_file_context'); const context = new ReadFileContext(callback, options.encoding); context.isUserFd = isFd(path); // File descriptor ownership @@ -2234,8 +2233,6 @@ function watch(filename, options, listener) { if (options.recursive === undefined) options.recursive = false; if (options.recursive && !(isOSX || isWindows)) throw new ERR_FEATURE_UNAVAILABLE_ON_PLATFORM('watch recursively'); - if (!watchers) - watchers = require('internal/fs/watchers'); const watcher = new watchers.FSWatcher(); watcher[watchers.kFSWatchStart](filename, options.persistent, @@ -2301,8 +2298,6 @@ function watchFile(filename, options, listener) { stat = statWatchers.get(filename); if (stat === undefined) { - if (!watchers) - watchers = require('internal/fs/watchers'); stat = new watchers.StatWatcher(options.bigint); stat[watchers.kFSStatWatcherStart](filename, options.persistent, options.interval); |