diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2021-05-19 21:30:47 +0300 |
---|---|---|
committer | Danielle Adams <adamzdanielle@gmail.com> | 2021-05-31 22:34:56 +0300 |
commit | 5d9442a024622327fdb7b4c158bb10a6d3461931 (patch) | |
tree | cc80281e1f8ed36d322715946953bba3e76c522e /lib | |
parent | a1b0e641873aa3c26cb30399aba485b0bb4a7123 (diff) |
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')
-rw-r--r-- | lib/fs.js | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/fs.js b/lib/fs.js index 310397bbed3..46209a3f4d5 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -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); |