Skip to content

Commit 8bded05

Browse files
cjihrigBethGriggs
authored andcommitted
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: #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>
1 parent 9ff1abf commit 8bded05

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/fs.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,11 @@ const {
8686
validateUint32
8787
} = require('internal/validators');
8888

89-
let promisesWarn = true;
9089
let truncateWarn = true;
9190
let fs;
9291

9392
// Lazy loaded
94-
let promises;
93+
let promises = null;
9594
let watchers;
9695
let ReadFileContext;
9796

@@ -1837,9 +1836,8 @@ Object.defineProperties(fs, {
18371836
configurable: true,
18381837
enumerable: false,
18391838
get() {
1840-
if (promisesWarn) {
1839+
if (promises === null) {
18411840
promises = require('internal/fs/promises');
1842-
promisesWarn = false;
18431841
process.emitWarning('The fs.promises API is experimental',
18441842
'ExperimentalWarning');
18451843
}

0 commit comments

Comments
 (0)