1 | // Type definitions for find-cache-dir 3.2
|
2 | // Project: https://github.com/avajs/find-cache-dir#readme
|
3 | // Definitions by: BendingBender <https://github.com/BendingBender>
|
4 | // Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
5 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
6 |
|
7 | export = findCacheDir;
|
8 |
|
9 | /**
|
10 | * Finds the cache directory using the supplied options.
|
11 | * The algorithm tries to find a `package.json` file, searching every parent directory of the `cwd` specified
|
12 | * (or implied from other options). It returns a `string` containing the absolute path to the cache directory,
|
13 | * or `undefined` if `package.json` was never found or if the `node_modules` directory is unwritable.
|
14 | */
|
15 | declare function findCacheDir(options: findCacheDir.OptionsWithThunk): ((...pathParts: string[]) => string) | undefined;
|
16 | declare function findCacheDir(options: findCacheDir.Options): string | undefined;
|
17 |
|
18 | declare namespace findCacheDir {
|
19 | interface Options {
|
20 | /**
|
21 | * Should be the same as your project name in `package.json`.
|
22 | */
|
23 | name: string;
|
24 |
|
25 | /**
|
26 | * An array of files that will be searched for a common parent directory.
|
27 | * This common parent directory will be used in lieu of the `cwd` option below.
|
28 | */
|
29 | files?: string | string[];
|
30 |
|
31 | /**
|
32 | * Directory to start searching for a `package.json` from.
|
33 | */
|
34 | cwd?: string;
|
35 |
|
36 | /**
|
37 | * If `true`, the directory will be created synchronously before returning.
|
38 | * @default false
|
39 | */
|
40 | create?: boolean;
|
41 |
|
42 | /**
|
43 | * If `true`, this modifies the return type to be a function that is a thunk for `path.join(theFoundCacheDirectory)`.
|
44 | * @default false
|
45 | */
|
46 | thunk?: boolean;
|
47 | }
|
48 |
|
49 | interface OptionsWithThunk extends Options {
|
50 | /**
|
51 | * If `true`, this modifies the return type to be a function that is a thunk for `path.join(theFoundCacheDirectory)`.
|
52 | * @default false
|
53 | */
|
54 | thunk: true;
|
55 | }
|
56 | }
|