sync.js 619 B

1234567891011121314151617181920212223
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.read = void 0;
  4. function read(path, settings) {
  5. const lstat = settings.fs.lstatSync(path);
  6. if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
  7. return lstat;
  8. }
  9. try {
  10. const stat = settings.fs.statSync(path);
  11. if (settings.markSymbolicLink) {
  12. stat.isSymbolicLink = () => true;
  13. }
  14. return stat;
  15. }
  16. catch (error) {
  17. if (!settings.throwErrorOnBrokenSymbolicLink) {
  18. return lstat;
  19. }
  20. throw error;
  21. }
  22. }
  23. exports.read = read;