Newer
Older
CVSS_3.0_GUI / dist / CVSS_3.0_Calc-1.0.0-linux-x64 / node_modules / nwjs-builder-phoenix / node_modules / fs-extra / lib / fs / index.js
root on 7 May 2019 1 KB Initial commit
  1. // This is adapted from https://github.com/normalize/mz
  2. // Copyright (c) 2014-2016 Jonathan Ong me@jongleberry.com and Contributors
  3. const u = require('universalify').fromCallback
  4. const fs = require('graceful-fs')
  5.  
  6. const api = [
  7. 'access',
  8. 'appendFile',
  9. 'chmod',
  10. 'chown',
  11. 'close',
  12. 'fchmod',
  13. 'fchown',
  14. 'fdatasync',
  15. 'fstat',
  16. 'fsync',
  17. 'ftruncate',
  18. 'futimes',
  19. 'lchown',
  20. 'link',
  21. 'lstat',
  22. 'mkdir',
  23. 'open',
  24. 'read',
  25. 'readFile',
  26. 'readdir',
  27. 'readlink',
  28. 'realpath',
  29. 'rename',
  30. 'rmdir',
  31. 'stat',
  32. 'symlink',
  33. 'truncate',
  34. 'unlink',
  35. 'utimes',
  36. 'write',
  37. 'writeFile'
  38. ]
  39. // fs.mkdtemp() was added in Node.js v5.10.0, so check if it exists
  40. typeof fs.mkdtemp === 'function' && api.push('mkdtemp')
  41.  
  42. // Export all keys:
  43. Object.keys(fs).forEach(key => {
  44. exports[key] = fs[key]
  45. })
  46.  
  47. // Universalify async methods:
  48. api.forEach(method => {
  49. exports[method] = u(fs[method])
  50. })
  51.  
  52. // We differ from mz/fs in that we still ship the old, broken, fs.exists()
  53. // since we are a drop-in replacement for the native module
  54. exports.exists = function (filename, callback) {
  55. if (typeof callback === 'function') {
  56. return fs.exists(filename, callback)
  57. }
  58. return new Promise(resolve => {
  59. return fs.exists(filename, resolve)
  60. })
  61. }
Buy Me A Coffee