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 type SearchStrategy = 'none' | 'project' | 'global';
|
37 |
|
38 |
|
39 |
|
40 | export interface CommonOptions {
|
41 | packageProp?: string | Array<string>;
|
42 | searchPlaces: Array<string>;
|
43 | ignoreEmptySearchPlaces: boolean;
|
44 | stopDir?: string;
|
45 | cache: boolean;
|
46 | mergeImportArrays: boolean;
|
47 | mergeSearchPlaces: boolean;
|
48 | searchStrategy: SearchStrategy;
|
49 | }
|
50 |
|
51 |
|
52 |
|
53 | export interface Options extends CommonOptions {
|
54 | loaders: Loaders;
|
55 | transform: Transform;
|
56 | }
|
57 |
|
58 |
|
59 |
|
60 | export interface OptionsSync extends CommonOptions {
|
61 | loaders: LoadersSync;
|
62 | transform: TransformSync;
|
63 | }
|
64 |
|
65 |
|
66 |
|
67 | export interface Loaders {
|
68 | [key: string]: Loader;
|
69 | }
|
70 |
|
71 |
|
72 |
|
73 | export interface LoadersSync {
|
74 | [key: string]: LoaderSync;
|
75 | }
|
76 |
|
77 |
|
78 |
|
79 | export interface PublicExplorerBase {
|
80 | clearLoadCache: () => void;
|
81 | clearSearchCache: () => void;
|
82 | clearCaches: () => void;
|
83 | }
|
84 |
|
85 |
|
86 |
|
87 | export interface PublicExplorer extends PublicExplorerBase {
|
88 | search: (searchFrom?: string) => Promise<CosmiconfigResult>;
|
89 | load: (filepath: string) => Promise<CosmiconfigResult>;
|
90 | }
|
91 |
|
92 |
|
93 |
|
94 | export interface PublicExplorerSync extends PublicExplorerBase {
|
95 | search: (searchFrom?: string) => CosmiconfigResult;
|
96 | load: (filepath: string) => CosmiconfigResult;
|
97 | }
|
98 |
|
\ | No newline at end of file |