Last change
on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | declare namespace locatePath {
|
---|
| 2 | interface Options {
|
---|
| 3 | /**
|
---|
| 4 | Current working directory.
|
---|
| 5 |
|
---|
| 6 | @default process.cwd()
|
---|
| 7 | */
|
---|
| 8 | readonly cwd?: string;
|
---|
| 9 |
|
---|
| 10 | /**
|
---|
| 11 | Type of path to match.
|
---|
| 12 |
|
---|
| 13 | @default 'file'
|
---|
| 14 | */
|
---|
| 15 | readonly type?: 'file' | 'directory';
|
---|
| 16 |
|
---|
| 17 | /**
|
---|
| 18 | Allow symbolic links to match if they point to the requested path type.
|
---|
| 19 |
|
---|
| 20 | @default true
|
---|
| 21 | */
|
---|
| 22 | readonly allowSymlinks?: boolean;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | interface AsyncOptions extends Options {
|
---|
| 26 | /**
|
---|
| 27 | Number of concurrently pending promises. Minimum: `1`.
|
---|
| 28 |
|
---|
| 29 | @default Infinity
|
---|
| 30 | */
|
---|
| 31 | readonly concurrency?: number;
|
---|
| 32 |
|
---|
| 33 | /**
|
---|
| 34 | Preserve `paths` order when searching.
|
---|
| 35 |
|
---|
| 36 | Disable this to improve performance if you don't care about the order.
|
---|
| 37 |
|
---|
| 38 | @default true
|
---|
| 39 | */
|
---|
| 40 | readonly preserveOrder?: boolean;
|
---|
| 41 | }
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | declare const locatePath: {
|
---|
| 45 | /**
|
---|
| 46 | Get the first path that exists on disk of multiple paths.
|
---|
| 47 |
|
---|
| 48 | @param paths - Paths to check.
|
---|
| 49 | @returns The first path that exists or `undefined` if none exists.
|
---|
| 50 |
|
---|
| 51 | @example
|
---|
| 52 | ```
|
---|
| 53 | import locatePath = require('locate-path');
|
---|
| 54 |
|
---|
| 55 | const files = [
|
---|
| 56 | 'unicorn.png',
|
---|
| 57 | 'rainbow.png', // Only this one actually exists on disk
|
---|
| 58 | 'pony.png'
|
---|
| 59 | ];
|
---|
| 60 |
|
---|
| 61 | (async () => {
|
---|
| 62 | console(await locatePath(files));
|
---|
| 63 | //=> 'rainbow'
|
---|
| 64 | })();
|
---|
| 65 | ```
|
---|
| 66 | */
|
---|
| 67 | (paths: Iterable<string>, options?: locatePath.AsyncOptions): Promise<
|
---|
| 68 | string | undefined
|
---|
| 69 | >;
|
---|
| 70 |
|
---|
| 71 | /**
|
---|
| 72 | Synchronously get the first path that exists on disk of multiple paths.
|
---|
| 73 |
|
---|
| 74 | @param paths - Paths to check.
|
---|
| 75 | @returns The first path that exists or `undefined` if none exists.
|
---|
| 76 | */
|
---|
| 77 | sync(
|
---|
| 78 | paths: Iterable<string>,
|
---|
| 79 | options?: locatePath.Options
|
---|
| 80 | ): string | undefined;
|
---|
| 81 | };
|
---|
| 82 |
|
---|
| 83 | export = locatePath;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.