Skip to content

Commit

Permalink
fs: simplify fs.promises warning logic
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cjihrig authored and BethGriggs committed Feb 12, 2019
1 parent 546fc68 commit 576d9c5
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1837,9 +1836,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');
}
Expand Down

0 comments on commit 576d9c5

Please sign in to comment.