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:
parent
585380d233
commit
7ac939e106
@ -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;
|
||||
@ -1931,9 +1930,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');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user