mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
fs: simplify fs.promises warning logic
fs.promises is lazy loaded. Instead of using a seaparate Boolean flag to track whether or not it has been loaded, just inspect the state of the lazy loaded module itself. PR-URL: https://github.com/nodejs/node/pull/24788 Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
1 parent
63b06b55d7
commit
124fca0267
1 file changed
+2
-4
@@ -86,12 +86,11 @@ const {
|
||||
validateUint32
|
||||
} = require('internal/validators');
|
||||
|
||||
let promisesWarn = true;
|
||||
let truncateWarn = true;
|
||||
let fs;
|
||||
|
||||
// Lazy loaded
|
||||
let promises;
|
||||
let promises = null;
|
||||
let watchers;
|
||||
let ReadFileContext;
|
||||
let ReadStream;
|
||||
@@ -1900,9 +1899,8 @@ Object.defineProperties(fs, {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
get() {
|
||||
if (promisesWarn) {
|
||||
if (promises === null) {
|
||||
promises = require('internal/fs/promises');
|
||||
promisesWarn = false;
|
||||
process.emitWarning('The fs.promises API is experimental',
|
||||
'ExperimentalWarning');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user