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 BridgeAR committed Dec 5, 2018
1 parent 63b06b5 commit 124fca0
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;
let ReadStream;
Expand Down Expand Up @@ -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');
}
Expand Down

0 comments on commit 124fca0

Please sign in to comment.