diff --git a/lib/fs.js b/lib/fs.js index e9d878803ddffd..ed2a241e568cf5 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -77,7 +77,7 @@ let warn = true; Object.defineProperty(fs, 'promises', { configurable: true, - enumerable: true, + enumerable: false, get() { if (warn) { warn = false; diff --git a/test/parallel/test-fs-promises.js b/test/parallel/test-fs-promises.js index 43b5da700484ff..8f1d646bb0e01e 100644 --- a/test/parallel/test-fs-promises.js +++ b/test/parallel/test-fs-promises.js @@ -5,7 +5,8 @@ const assert = require('assert'); const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); const path = require('path'); -const fsPromises = require('fs').promises; +const fs = require('fs'); +const fsPromises = fs.promises; const { access, chmod, @@ -38,6 +39,10 @@ const tmpDir = tmpdir.path; common.crashOnUnhandledRejection(); +// fs.promises should not be enumerable as long as it causes a warning to be +// emitted. +assert.strictEqual(Object.keys(fs).includes('promises'), false); + { access(__filename, 'r') .then(common.mustCall())