Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

index.d.ts 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import {Options as FastGlobOptions} from 'fast-glob';
  2. declare namespace globby {
  3. type ExpandDirectoriesOption =
  4. | boolean
  5. | readonly string[]
  6. | {files?: readonly string[]; extensions?: readonly string[]};
  7. interface GlobbyOptions extends FastGlobOptions {
  8. /**
  9. If set to `true`, `globby` will automatically glob directories for you. If you define an `Array` it will only glob files that matches the patterns inside the `Array`. You can also define an `Object` with `files` and `extensions` like in the example below.
  10. Note that if you set this option to `false`, you won't get back matched directories unless you set `onlyFiles: false`.
  11. @default true
  12. @example
  13. ```
  14. import globby = require('globby');
  15. (async () => {
  16. const paths = await globby('images', {
  17. expandDirectories: {
  18. files: ['cat', 'unicorn', '*.jpg'],
  19. extensions: ['png']
  20. }
  21. });
  22. console.log(paths);
  23. //=> ['cat.png', 'unicorn.png', 'cow.jpg', 'rainbow.jpg']
  24. })();
  25. ```
  26. */
  27. readonly expandDirectories?: ExpandDirectoriesOption;
  28. /**
  29. Respect ignore patterns in `.gitignore` files that apply to the globbed files.
  30. @default false
  31. */
  32. readonly gitignore?: boolean;
  33. }
  34. interface GlobTask {
  35. readonly pattern: string;
  36. readonly options: globby.GlobbyOptions;
  37. }
  38. interface GitignoreOptions {
  39. readonly cwd?: string;
  40. readonly ignore?: readonly string[];
  41. }
  42. type FilterFunction = (path: string) => boolean;
  43. }
  44. interface Gitignore {
  45. /**
  46. `.gitignore` files matched by the ignore config are not used for the resulting filter function.
  47. @returns A filter function indicating whether a given path is ignored via a `.gitignore` file.
  48. @example
  49. ```
  50. import {gitignore} from 'globby';
  51. (async () => {
  52. const isIgnored = await gitignore();
  53. console.log(isIgnored('some/file'));
  54. })();
  55. ```
  56. */
  57. (options?: globby.GitignoreOptions): Promise<globby.FilterFunction>;
  58. /**
  59. @returns A filter function indicating whether a given path is ignored via a `.gitignore` file.
  60. */
  61. sync(options?: globby.GitignoreOptions): globby.FilterFunction;
  62. }
  63. declare const globby: {
  64. /**
  65. Find files and directories using glob patterns.
  66. Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
  67. @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
  68. @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
  69. @returns The matching paths.
  70. @example
  71. ```
  72. import globby = require('globby');
  73. (async () => {
  74. const paths = await globby(['*', '!cake']);
  75. console.log(paths);
  76. //=> ['unicorn', 'rainbow']
  77. })();
  78. ```
  79. */
  80. (
  81. patterns: string | readonly string[],
  82. options?: globby.GlobbyOptions
  83. ): Promise<string[]>;
  84. /**
  85. Find files and directories using glob patterns.
  86. Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
  87. @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
  88. @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
  89. @returns The matching paths.
  90. */
  91. sync(
  92. patterns: string | readonly string[],
  93. options?: globby.GlobbyOptions
  94. ): string[];
  95. /**
  96. Find files and directories using glob patterns.
  97. Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
  98. @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
  99. @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
  100. @returns The stream of matching paths.
  101. @example
  102. ```
  103. import globby = require('globby');
  104. (async () => {
  105. for await (const path of globby.stream('*.tmp')) {
  106. console.log(path);
  107. }
  108. })();
  109. ```
  110. */
  111. stream(
  112. patterns: string | readonly string[],
  113. options?: globby.GlobbyOptions
  114. ): NodeJS.ReadableStream;
  115. /**
  116. Note that you should avoid running the same tasks multiple times as they contain a file system cache. Instead, run this method each time to ensure file system changes are taken into consideration.
  117. @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
  118. @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
  119. @returns An object in the format `{pattern: string, options: object}`, which can be passed as arguments to [`fast-glob`](https://github.com/mrmlnc/fast-glob). This is useful for other globbing-related packages.
  120. */
  121. generateGlobTasks(
  122. patterns: string | readonly string[],
  123. options?: globby.GlobbyOptions
  124. ): globby.GlobTask[];
  125. /**
  126. Note that the options affect the results.
  127. This function is backed by [`fast-glob`](https://github.com/mrmlnc/fast-glob#isdynamicpatternpattern-options).
  128. @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
  129. @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3).
  130. @returns Whether there are any special glob characters in the `patterns`.
  131. */
  132. hasMagic(
  133. patterns: string | readonly string[],
  134. options?: FastGlobOptions
  135. ): boolean;
  136. readonly gitignore: Gitignore;
  137. };
  138. export = globby;