diff --git a/lib/__tests__/promise.test.js b/lib/__tests__/promise.test.js index 09417fde4..31228bdf4 100644 --- a/lib/__tests__/promise.test.js +++ b/lib/__tests__/promise.test.js @@ -3,7 +3,6 @@ /* eslint-env mocha */ const assert = require('assert') -const fs = require('fs') const fse = require('..') const methods = [ @@ -24,11 +23,8 @@ describe('promise support', () => { }) }) - if (Object.getOwnPropertyDescriptor(fs, 'promises')) { - it('provides fse.promises API', () => { - const desc = Object.getOwnPropertyDescriptor(fse, 'promises') - assert.ok(desc) - assert.strictEqual(typeof desc.get, 'function') - }) - } + it('provides fse.promises API', () => { + assert.ok(fse.promises) + assert.strictEqual(typeof fse.promises.writeFile, 'function') + }) }) diff --git a/lib/fs/index.js b/lib/fs/index.js index 93fe6a035..e460b747c 100644 --- a/lib/fs/index.js +++ b/lib/fs/index.js @@ -47,15 +47,8 @@ const api = [ return typeof fs[key] === 'function' }) -// Export all keys: -Object.keys(fs).forEach(key => { - if (key === 'promises') { - // fs.promises is a getter property that triggers ExperimentalWarning - // Don't re-export it here, the getter is defined in "lib/index.js" - return - } - exports[key] = fs[key] -}) +// Export cloned fs: +Object.assign(exports, fs) // Universalify async methods: api.forEach(method => { diff --git a/lib/index.js b/lib/index.js index d9468e699..cbc2aaec3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -16,12 +16,3 @@ module.exports = { ...require('./path-exists'), ...require('./remove') } - -// Export fs.promises as a getter property so that we don't trigger -// ExperimentalWarning before fs.promises is actually accessed. -const fs = require('fs') -if (Object.getOwnPropertyDescriptor(fs, 'promises')) { - Object.defineProperty(module.exports, 'promises', { - get () { return fs.promises } - }) -}