tryRealpath.js 649 B

12345678910111213141516171819202122232425262728293031323334
  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) Facebook, Inc. and its affiliates. All Rights Reserved.
  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') {
  24. throw error;
  25. }
  26. }
  27. return path;
  28. }