cosmiconfig

  • Version 9.0.0
  • Published
  • 124 kB
  • 4 dependencies
  • MIT license

Install

npm i cosmiconfig
yarn add cosmiconfig
pnpm add cosmiconfig

Overview

Find and load configuration from a package.json property, rc file, TypeScript module, and more!

Index

Variables

variable defaultLoaders

const defaultLoaders: Readonly<{
readonly '.mjs': import('./types').Loader;
readonly '.cjs': import('./types').Loader;
readonly '.js': import('./types').Loader;
readonly '.ts': import('./types').Loader;
readonly '.json': import('./types').LoaderSync;
readonly '.yaml': import('./types').LoaderSync;
readonly '.yml': import('./types').LoaderSync;
readonly noExt: import('./types').LoaderSync;
}>;

    variable defaultLoadersSync

    const defaultLoadersSync: Readonly<{
    readonly '.cjs': import('./types').LoaderSync;
    readonly '.js': import('./types').LoaderSync;
    readonly '.ts': import('./types').LoaderSync;
    readonly '.json': import('./types').LoaderSync;
    readonly '.yaml': import('./types').LoaderSync;
    readonly '.yml': import('./types').LoaderSync;
    readonly noExt: import('./types').LoaderSync;
    }>;

      variable globalConfigSearchPlaces

      const globalConfigSearchPlaces: string[];

        variable globalConfigSearchPlacesSync

        const globalConfigSearchPlacesSync: string[];

          Functions

          function cosmiconfig

          cosmiconfig: (
          moduleName: string,
          options?: Readonly<Partial<Options>>
          ) => PublicExplorer;

            function cosmiconfigSync

            cosmiconfigSync: (
            moduleName: string,
            options?: Readonly<Partial<OptionsSync>>
            ) => PublicExplorerSync;

              function getDefaultSearchPlaces

              getDefaultSearchPlaces: (moduleName: string) => Array<string>;

                function getDefaultSearchPlacesSync

                getDefaultSearchPlacesSync: (moduleName: string) => Array<string>;

                  Interfaces

                  interface CommonOptions

                  interface CommonOptions {}
                  • Modifiers

                    • @public

                  property cache

                  cache: boolean;

                    property ignoreEmptySearchPlaces

                    ignoreEmptySearchPlaces: boolean;

                      property mergeImportArrays

                      mergeImportArrays: boolean;

                        property mergeSearchPlaces

                        mergeSearchPlaces: boolean;

                          property packageProp

                          packageProp?: string | Array<string>;

                            property searchPlaces

                            searchPlaces: Array<string>;

                              property searchStrategy

                              searchStrategy: SearchStrategy;

                                property stopDir

                                stopDir?: string;

                                  interface Loaders

                                  interface Loaders {}
                                  • Modifiers

                                    • @public

                                  index signature

                                  [key: string]: Loader;

                                    interface LoadersSync

                                    interface LoadersSync {}
                                    • Modifiers

                                      • @public

                                    index signature

                                    [key: string]: LoaderSync;

                                      interface Options

                                      interface Options extends CommonOptions {}
                                      • Modifiers

                                        • @public

                                      property loaders

                                      loaders: Loaders;

                                        property transform

                                        transform: Transform;

                                          interface OptionsSync

                                          interface OptionsSync extends CommonOptions {}
                                          • Modifiers

                                            • @public

                                          property loaders

                                          loaders: LoadersSync;

                                            property transform

                                            transform: TransformSync;

                                              interface PublicExplorer

                                              interface PublicExplorer extends PublicExplorerBase {}
                                              • Modifiers

                                                • @public

                                              property load

                                              load: (filepath: string) => Promise<CosmiconfigResult>;

                                                property search

                                                search: (searchFrom?: string) => Promise<CosmiconfigResult>;

                                                  interface PublicExplorerBase

                                                  interface PublicExplorerBase {}
                                                  • Modifiers

                                                    • @public

                                                  property clearCaches

                                                  clearCaches: () => void;

                                                    property clearLoadCache

                                                    clearLoadCache: () => void;

                                                      property clearSearchCache

                                                      clearSearchCache: () => void;

                                                        interface PublicExplorerSync

                                                        interface PublicExplorerSync extends PublicExplorerBase {}
                                                        • Modifiers

                                                          • @public

                                                        property load

                                                        load: (filepath: string) => CosmiconfigResult;

                                                          property search

                                                          search: (searchFrom?: string) => CosmiconfigResult;

                                                            Type Aliases

                                                            type Config

                                                            type Config = any;
                                                            • Modifiers

                                                              • @public

                                                            type CosmiconfigResult

                                                            type CosmiconfigResult = {
                                                            config: Config;
                                                            filepath: string;
                                                            isEmpty?: boolean;
                                                            } | null;
                                                            • Modifiers

                                                              • @public

                                                            type Loader

                                                            type Loader =
                                                            | ((filepath: string, content: string) => Promise<LoaderResult>)
                                                            | LoaderSync;
                                                            • Modifiers

                                                              • @public

                                                            type LoaderResult

                                                            type LoaderResult = Config | null;
                                                            • Modifiers

                                                              • @public

                                                            type LoaderSync

                                                            type LoaderSync = (filepath: string, content: string) => LoaderResult;
                                                            • Modifiers

                                                              • @public

                                                            type SearchStrategy

                                                            type SearchStrategy = 'none' | 'project' | 'global';
                                                            • Modifiers

                                                              • @public

                                                            type Transform

                                                            type Transform =
                                                            | ((CosmiconfigResult: CosmiconfigResult) => Promise<CosmiconfigResult>)
                                                            | TransformSync;
                                                            • Modifiers

                                                              • @public

                                                            type TransformSync

                                                            type TransformSync = (CosmiconfigResult: CosmiconfigResult) => CosmiconfigResult;
                                                            • Modifiers

                                                              • @public

                                                            Package Files (3)

                                                            Dependencies (4)

                                                            Dev Dependencies (21)

                                                            Peer Dependencies (1)

                                                            Badge

                                                            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/cosmiconfig.

                                                            • Markdown
                                                              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/cosmiconfig)
                                                            • HTML
                                                              <a href="https://www.jsdocs.io/package/cosmiconfig"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>