pattern.d.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /// <reference types="node" />
  2. import { GLOBSTAR } from 'minimatch';
  3. export type MMPattern = string | RegExp | typeof GLOBSTAR;
  4. export type PatternList = [p: MMPattern, ...rest: MMPattern[]];
  5. export type UNCPatternList = [
  6. p0: '',
  7. p1: '',
  8. p2: string,
  9. p3: string,
  10. ...rest: MMPattern[]
  11. ];
  12. export type DrivePatternList = [p0: string, ...rest: MMPattern[]];
  13. export type AbsolutePatternList = [p0: '', ...rest: MMPattern[]];
  14. export type GlobList = [p: string, ...rest: string[]];
  15. /**
  16. * An immutable-ish view on an array of glob parts and their parsed
  17. * results
  18. */
  19. export declare class Pattern {
  20. #private;
  21. readonly length: number;
  22. constructor(patternList: MMPattern[], globList: string[], index: number, platform: NodeJS.Platform);
  23. /**
  24. * The first entry in the parsed list of patterns
  25. */
  26. pattern(): MMPattern;
  27. /**
  28. * true of if pattern() returns a string
  29. */
  30. isString(): boolean;
  31. /**
  32. * true of if pattern() returns GLOBSTAR
  33. */
  34. isGlobstar(): boolean;
  35. /**
  36. * true if pattern() returns a regexp
  37. */
  38. isRegExp(): boolean;
  39. /**
  40. * The /-joined set of glob parts that make up this pattern
  41. */
  42. globString(): string;
  43. /**
  44. * true if there are more pattern parts after this one
  45. */
  46. hasMore(): boolean;
  47. /**
  48. * The rest of the pattern after this part, or null if this is the end
  49. */
  50. rest(): Pattern | null;
  51. /**
  52. * true if the pattern represents a //unc/path/ on windows
  53. */
  54. isUNC(): boolean;
  55. /**
  56. * True if the pattern starts with a drive letter on Windows
  57. */
  58. isDrive(): boolean;
  59. /**
  60. * True if the pattern is rooted on an absolute path
  61. */
  62. isAbsolute(): boolean;
  63. /**
  64. * consume the root of the pattern, and return it
  65. */
  66. root(): string;
  67. /**
  68. * True if the pattern has any non-string components
  69. */
  70. hasMagic(): boolean;
  71. /**
  72. * Check to see if the current globstar pattern is allowed to follow
  73. * a symbolic link.
  74. */
  75. checkFollowGlobstar(): boolean;
  76. /**
  77. * Mark that the current globstar pattern is following a symbolic link
  78. */
  79. markFollowGlobstar(): boolean;
  80. }