1 |
|
2 |
|
3 |
|
4 | export type Config = any;
|
5 |
|
6 |
|
7 |
|
8 | export type CosmiconfigResult = {
|
9 | config: Config;
|
10 | filepath: string;
|
11 | isEmpty?: boolean;
|
12 | } | null;
|
13 |
|
14 |
|
15 |
|
16 | export type LoaderResult = Config | null;
|
17 |
|
18 |
|
19 |
|
20 | export type Loader = ((filepath: string, content: string) => Promise<LoaderResult>) | LoaderSync;
|
21 | /**
|
22 | * @public
|
23 | */
|
24 | export type LoaderSync = (filepath: string, content: string) => LoaderResult;
|
25 |
|
26 |
|
27 |
|
28 | export type Transform = ((CosmiconfigResult: CosmiconfigResult) => Promise<CosmiconfigResult>) | TransformSync;
|
29 | /**
|
30 | * @public
|
31 | */
|
32 | export type TransformSync = (CosmiconfigResult: CosmiconfigResult) => CosmiconfigResult;
|
33 |
|
34 |
|
35 |
|
36 | export interface CommonOptions {
|
37 | packageProp?: string | Array<string>;
|
38 | searchPlaces?: Array<string>;
|
39 | ignoreEmptySearchPlaces?: boolean;
|
40 | stopDir?: string;
|
41 | cache?: boolean;
|
42 | }
|
43 |
|
44 |
|
45 |
|
46 | export interface Options extends CommonOptions {
|
47 | loaders?: Loaders;
|
48 | transform?: Transform;
|
49 | }
|
50 |
|
51 |
|
52 |
|
53 | export interface OptionsSync extends CommonOptions {
|
54 | loaders?: LoadersSync;
|
55 | transform?: TransformSync;
|
56 | }
|
57 |
|
58 |
|
59 |
|
60 | export interface Loaders {
|
61 | [key: string]: Loader;
|
62 | }
|
63 |
|
64 |
|
65 |
|
66 | export interface LoadersSync {
|
67 | [key: string]: LoaderSync;
|
68 | }
|
69 |
|
70 |
|
71 |
|
72 | export interface PublicExplorerBase {
|
73 | clearLoadCache: () => void;
|
74 | clearSearchCache: () => void;
|
75 | clearCaches: () => void;
|
76 | }
|
77 |
|
78 |
|
79 |
|
80 | export interface PublicExplorer extends PublicExplorerBase {
|
81 | search: (searchFrom?: string) => Promise<CosmiconfigResult>;
|
82 | load: (filepath: string) => Promise<CosmiconfigResult>;
|
83 | }
|
84 |
|
85 |
|
86 |
|
87 | export interface PublicExplorerSync extends PublicExplorerBase {
|
88 | search: (searchFrom?: string) => CosmiconfigResult;
|
89 | load: (filepath: string) => CosmiconfigResult;
|
90 | }
|
91 |
|
\ | No newline at end of file |