UNPKG

2.07 kBTypeScriptView Raw
1/**
2 * @public
3 */
4export type Config = any;
5/**
6 * @public
7 */
8export type CosmiconfigResult = {
9 config: Config;
10 filepath: string;
11 isEmpty?: boolean;
12} | null;
13/**
14 * @public
15 */
16export type LoaderResult = Config | null;
17/**
18 * @public
19 */
20export type Loader = ((filepath: string, content: string) => Promise<LoaderResult>) | LoaderSync;
21/**
22 * @public
23 */
24export type LoaderSync = (filepath: string, content: string) => LoaderResult;
25/**
26 * @public
27 */
28export type Transform = ((CosmiconfigResult: CosmiconfigResult) => Promise<CosmiconfigResult>) | TransformSync;
29/**
30 * @public
31 */
32export type TransformSync = (CosmiconfigResult: CosmiconfigResult) => CosmiconfigResult;
33/**
34 * @public
35 */
36export type SearchStrategy = 'none' | 'project' | 'global';
37/**
38 * @public
39 */
40export 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 * @public
52 */
53export interface Options extends CommonOptions {
54 loaders: Loaders;
55 transform: Transform;
56}
57/**
58 * @public
59 */
60export interface OptionsSync extends CommonOptions {
61 loaders: LoadersSync;
62 transform: TransformSync;
63}
64/**
65 * @public
66 */
67export interface Loaders {
68 [key: string]: Loader;
69}
70/**
71 * @public
72 */
73export interface LoadersSync {
74 [key: string]: LoaderSync;
75}
76/**
77 * @public
78 */
79export interface PublicExplorerBase {
80 clearLoadCache: () => void;
81 clearSearchCache: () => void;
82 clearCaches: () => void;
83}
84/**
85 * @public
86 */
87export interface PublicExplorer extends PublicExplorerBase {
88 search: (searchFrom?: string) => Promise<CosmiconfigResult>;
89 load: (filepath: string) => Promise<CosmiconfigResult>;
90}
91/**
92 * @public
93 */
94export interface PublicExplorerSync extends PublicExplorerBase {
95 search: (searchFrom?: string) => CosmiconfigResult;
96 load: (filepath: string) => CosmiconfigResult;
97}
98//# sourceMappingURL=types.d.ts.map
\No newline at end of file