You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.5 KiB

2 years ago
  1. export declare type LilconfigResult = null | {
  2. filepath: string;
  3. config: any;
  4. isEmpty?: boolean;
  5. };
  6. interface OptionsBase {
  7. stopDir?: string;
  8. searchPlaces?: string[];
  9. ignoreEmptySearchPlaces?: boolean;
  10. packageProp?: string | string[];
  11. }
  12. export declare type Transform = TransformSync | ((result: LilconfigResult) => Promise<LilconfigResult>);
  13. export declare type TransformSync = (result: LilconfigResult) => LilconfigResult;
  14. declare type LoaderResult = any;
  15. export declare type LoaderSync = (filepath: string, content: string) => LoaderResult;
  16. export declare type Loader = LoaderSync | ((filepath: string, content: string) => Promise<LoaderResult>);
  17. export declare type Loaders = Record<string, Loader>;
  18. export declare type LoadersSync = Record<string, LoaderSync>;
  19. export interface Options extends OptionsBase {
  20. loaders?: Loaders;
  21. transform?: Transform;
  22. }
  23. export interface OptionsSync extends OptionsBase {
  24. loaders?: LoadersSync;
  25. transform?: TransformSync;
  26. }
  27. export declare const defaultLoaders: LoadersSync;
  28. declare type AsyncSearcher = {
  29. search(searchFrom?: string): Promise<LilconfigResult>;
  30. load(filepath: string): Promise<LilconfigResult>;
  31. };
  32. export declare function lilconfig(name: string, options?: Partial<Options>): AsyncSearcher;
  33. declare type SyncSearcher = {
  34. search(searchFrom?: string): LilconfigResult;
  35. load(filepath: string): LilconfigResult;
  36. };
  37. export declare function lilconfigSync(name: string, options?: OptionsSync): SyncSearcher;
  38. export {};