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.

39 lines
1.3 KiB

4 years ago
  1. /// <reference types="node" />
  2. import micromatch = require('micromatch');
  3. import DeepFilter from './filters/deep';
  4. import EntryFilter from './filters/entry';
  5. import { IOptions } from '../managers/options';
  6. import { ITask } from '../managers/tasks';
  7. import { Options as IReaddirOptions } from '@mrmlnc/readdir-enhanced';
  8. import { Entry, EntryItem } from '../types/entries';
  9. export default abstract class Reader<T> {
  10. readonly options: IOptions;
  11. readonly entryFilter: EntryFilter;
  12. readonly deepFilter: DeepFilter;
  13. private readonly micromatchOptions;
  14. constructor(options: IOptions);
  15. /**
  16. * The main logic of reading the directories that must be implemented by each providers.
  17. */
  18. abstract read(_task: ITask): T;
  19. /**
  20. * Returns root path to scanner.
  21. */
  22. getRootDirectory(task: ITask): string;
  23. /**
  24. * Returns options for reader.
  25. */
  26. getReaderOptions(task: ITask): IReaddirOptions;
  27. /**
  28. * Returns options for micromatch.
  29. */
  30. getMicromatchOptions(): micromatch.Options;
  31. /**
  32. * Returns transformed entry.
  33. */
  34. transform(entry: Entry): EntryItem;
  35. /**
  36. * Returns true if error has ENOENT code.
  37. */
  38. isEnoentCodeError(err: NodeJS.ErrnoException): boolean;
  39. }