tryRealpath.js 653 B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = tryRealpath;
  6. function _gracefulFs() {
  7. const data = require('graceful-fs');
  8. _gracefulFs = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. /**
  14. * Copyright (c) Meta Platforms, Inc. and affiliates.
  15. *
  16. * This source code is licensed under the MIT license found in the
  17. * LICENSE file in the root directory of this source tree.
  18. */
  19. function tryRealpath(path) {
  20. try {
  21. path = _gracefulFs().realpathSync.native(path);
  22. } catch (error) {
  23. if (error.code !== 'ENOENT' && error.code !== 'EISDIR') {
  24. throw error;
  25. }
  26. }
  27. return path;
  28. }