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.

33 lines
881 B

4 years ago
  1. # fs.realpath
  2. A backwards-compatible fs.realpath for Node v6 and above
  3. In Node v6, the JavaScript implementation of fs.realpath was replaced
  4. with a faster (but less resilient) native implementation. That raises
  5. new and platform-specific errors and cannot handle long or excessively
  6. symlink-looping paths.
  7. This module handles those cases by detecting the new errors and
  8. falling back to the JavaScript implementation. On versions of Node
  9. prior to v6, it has no effect.
  10. ## USAGE
  11. ```js
  12. var rp = require('fs.realpath')
  13. // async version
  14. rp.realpath(someLongAndLoopingPath, function (er, real) {
  15. // the ELOOP was handled, but it was a bit slower
  16. })
  17. // sync version
  18. var real = rp.realpathSync(someLongAndLoopingPath)
  19. // monkeypatch at your own risk!
  20. // This replaces the fs.realpath/fs.realpathSync builtins
  21. rp.monkeypatch()
  22. // un-do the monkeypatching
  23. rp.unmonkeypatch()
  24. ```