Skip to content

Commit

Permalink
Remove special handling of fs.promises
Browse files Browse the repository at this point in the history
Refs #886
  • Loading branch information
RyanZim committed Apr 22, 2021
1 parent ce29957 commit 5d756db
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
11 changes: 2 additions & 9 deletions lib/fs/index.js
Expand Up @@ -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 => {
Expand Down
9 changes: 0 additions & 9 deletions lib/index.js
Expand Up @@ -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 }
})
}

0 comments on commit 5d756db

Please sign in to comment.