Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING: Remove special handling of fs.promises #890

Merged
merged 2 commits into from Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 4 additions & 8 deletions lib/__tests__/promise.test.js
Expand Up @@ -3,7 +3,6 @@
/* eslint-env mocha */

const assert = require('assert')
const fs = require('fs')
const fse = require('..')

const methods = [
Expand All @@ -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')
})
})
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 }
})
}