mirror of
https://github.com/jprichardson/node-fs-extra.git
synced 2026-01-18 16:13:55 +00:00
BREAKING: Remove special handling of fs.promises (#890)
* Remove special handling of fs.promises Refs #886 * Fix tests
This commit is contained in:
parent
d8c93b8978
commit
05d2e93d99
@ -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')
|
||||
})
|
||||
})
|
||||
|
||||
@ -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 => {
|
||||
|
||||
@ -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 }
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user