Permalink
Browse files

fs: make fs.promises non-enumerable

This prevents the experimental feature warning from being emitted
in cases where fs.promises is not actually used.

PR-URL: #20632
Fixes: #20504
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
  • Loading branch information...
cjihrig committed May 9, 2018
1 parent 6fd8022 commit 20509ebee681233443ebc7dc1b58c2fab6d2b12f
Showing with 7 additions and 2 deletions.
  1. +1 −1 lib/fs.js
  2. +6 −1 test/parallel/test-fs-promises.js
View
@@ -79,7 +79,7 @@ let warn = true;
Object.defineProperty(fs, 'promises', {
configurable: true,
enumerable: true,
enumerable: false,
get() {
if (warn) {
warn = false;
@@ -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())

0 comments on commit 20509eb

Please sign in to comment.