From 576d9c513adef30fe33633c7f5d102d9d4f3c4b8 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 2 Dec 2018 12:08:26 -0500 Subject: [PATCH] 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 Reviewed-By: Weijia Wang Reviewed-By: Masashi Hirano Reviewed-By: Jeremiah Senkpiel --- lib/fs.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index 4b7ef8ffac9254..1eed27109465e0 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -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; @@ -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'); }