index.d.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { Config, CosmiconfigResult, Loaders, LoadersSync } from './types';
  2. declare type LoaderResult = Config | null;
  3. export declare type Loader = ((filepath: string, content: string) => Promise<LoaderResult>) | LoaderSync;
  4. export declare type LoaderSync = (filepath: string, content: string) => LoaderResult;
  5. export declare type Transform = ((CosmiconfigResult: CosmiconfigResult) => Promise<CosmiconfigResult>) | TransformSync;
  6. export declare type TransformSync = (CosmiconfigResult: CosmiconfigResult) => CosmiconfigResult;
  7. interface OptionsBase {
  8. packageProp?: string | Array<string>;
  9. searchPlaces?: Array<string>;
  10. ignoreEmptySearchPlaces?: boolean;
  11. stopDir?: string;
  12. cache?: boolean;
  13. }
  14. export interface Options extends OptionsBase {
  15. loaders?: Loaders;
  16. transform?: Transform;
  17. }
  18. export interface OptionsSync extends OptionsBase {
  19. loaders?: LoadersSync;
  20. transform?: TransformSync;
  21. }
  22. declare function cosmiconfig(moduleName: string, options?: Options): {
  23. readonly search: (searchFrom?: string) => Promise<CosmiconfigResult>;
  24. readonly load: (filepath: string) => Promise<CosmiconfigResult>;
  25. readonly clearLoadCache: () => void;
  26. readonly clearSearchCache: () => void;
  27. readonly clearCaches: () => void;
  28. };
  29. declare function cosmiconfigSync(moduleName: string, options?: OptionsSync): {
  30. readonly search: (searchFrom?: string) => CosmiconfigResult;
  31. readonly load: (filepath: string) => CosmiconfigResult;
  32. readonly clearLoadCache: () => void;
  33. readonly clearSearchCache: () => void;
  34. readonly clearCaches: () => void;
  35. };
  36. declare const defaultLoaders: Readonly<{
  37. readonly '.cjs': LoaderSync;
  38. readonly '.js': LoaderSync;
  39. readonly '.json': LoaderSync;
  40. readonly '.yaml': LoaderSync;
  41. readonly '.yml': LoaderSync;
  42. readonly noExt: LoaderSync;
  43. }>;
  44. export { cosmiconfig, cosmiconfigSync, defaultLoaders };
  45. //# sourceMappingURL=index.d.ts.map