You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wrapped-fs.js 606B

1234567891011121314151617181920212223242526
  1. 'use strict'
  2. const fs = process.versions.electron ? require('original-fs') : require('fs')
  3. const promisifiedMethods = [
  4. 'lstat',
  5. 'mkdtemp',
  6. 'readFile',
  7. 'stat',
  8. 'writeFile'
  9. ]
  10. const promisified = {}
  11. for (const method of Object.keys(fs)) {
  12. if (promisifiedMethods.includes(method)) {
  13. promisified[method] = fs.promises[method]
  14. } else {
  15. promisified[method] = fs[method]
  16. }
  17. }
  18. // To make it more like fs-extra
  19. promisified.mkdirp = (dir) => fs.promises.mkdir(dir, { recursive: true })
  20. promisified.mkdirpSync = (dir) => fs.mkdirSync(dir, { recursive: true })
  21. module.exports = promisified