Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. declare namespace locatePath {
  2. interface Options {
  3. /**
  4. Current working directory.
  5. @default process.cwd()
  6. */
  7. readonly cwd?: string;
  8. /**
  9. Type of path to match.
  10. @default 'file'
  11. */
  12. readonly type?: 'file' | 'directory';
  13. /**
  14. Allow symbolic links to match if they point to the requested path type.
  15. @default true
  16. */
  17. readonly allowSymlinks?: boolean;
  18. }
  19. interface AsyncOptions extends Options {
  20. /**
  21. Number of concurrently pending promises. Minimum: `1`.
  22. @default Infinity
  23. */
  24. readonly concurrency?: number;
  25. /**
  26. Preserve `paths` order when searching.
  27. Disable this to improve performance if you don't care about the order.
  28. @default true
  29. */
  30. readonly preserveOrder?: boolean;
  31. }
  32. }
  33. declare const locatePath: {
  34. /**
  35. Synchronously get the first path that exists on disk of multiple paths.
  36. @param paths - Paths to check.
  37. @returns The first path that exists or `undefined` if none exists.
  38. */
  39. sync: (
  40. paths: Iterable<string>,
  41. options?: locatePath.Options
  42. ) => string | undefined;
  43. /**
  44. Get the first path that exists on disk of multiple paths.
  45. @param paths - Paths to check.
  46. @returns The first path that exists or `undefined` if none exists.
  47. @example
  48. ```
  49. import locatePath = require('locate-path');
  50. const files = [
  51. 'unicorn.png',
  52. 'rainbow.png', // Only this one actually exists on disk
  53. 'pony.png'
  54. ];
  55. (async () => {
  56. console(await locatePath(files));
  57. //=> 'rainbow'
  58. })();
  59. ```
  60. */
  61. (paths: Iterable<string>, options?: locatePath.AsyncOptions): Promise<
  62. string | undefined
  63. >;
  64. };
  65. export = locatePath;