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.

59 lines
2.1 KiB

4 years ago
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. extendStatics(d, b);
  11. function __() { this.constructor = d; }
  12. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13. };
  14. })();
  15. Object.defineProperty(exports, "__esModule", { value: true });
  16. var fsStat = require("@nodelib/fs.stat");
  17. var fs_1 = require("./fs");
  18. var FileSystemSync = /** @class */ (function (_super) {
  19. __extends(FileSystemSync, _super);
  20. function FileSystemSync() {
  21. return _super !== null && _super.apply(this, arguments) || this;
  22. }
  23. /**
  24. * Use sync API to read entries for Task.
  25. */
  26. FileSystemSync.prototype.read = function (patterns, filter) {
  27. var _this = this;
  28. var entries = [];
  29. patterns.forEach(function (pattern) {
  30. var filepath = _this.getFullEntryPath(pattern);
  31. var entry = _this.getEntry(filepath, pattern);
  32. if (entry === null || !filter(entry)) {
  33. return;
  34. }
  35. entries.push(entry);
  36. });
  37. return entries;
  38. };
  39. /**
  40. * Return entry for the provided path.
  41. */
  42. FileSystemSync.prototype.getEntry = function (filepath, pattern) {
  43. try {
  44. var stat = this.getStat(filepath);
  45. return this.makeEntry(stat, pattern);
  46. }
  47. catch (err) {
  48. return null;
  49. }
  50. };
  51. /**
  52. * Return fs.Stats for the provided path.
  53. */
  54. FileSystemSync.prototype.getStat = function (filepath) {
  55. return fsStat.statSync(filepath, { throwErrorOnBrokenSymlinks: false });
  56. };
  57. return FileSystemSync;
  58. }(fs_1.default));
  59. exports.default = FileSystemSync;