reader.d.ts 1.3 KB

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