cosmiconfig

  • Version 8.3.6
  • Published
  • 78.5 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.js').Loader;
readonly '.cjs': import('./types.js').Loader;
readonly '.js': import('./types.js').Loader;
readonly '.ts': import('./types.js').Loader;
readonly '.json': import('./types.js').LoaderSync;
readonly '.yaml': import('./types.js').LoaderSync;
readonly '.yml': import('./types.js').LoaderSync;
readonly noExt: import('./types.js').LoaderSync;
}>;

    variable defaultLoadersSync

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

      variable metaSearchPlaces

      const metaSearchPlaces: string[];

        Functions

        function cosmiconfig

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

          function cosmiconfigSync

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

            Interfaces

            interface CommonOptions

            interface CommonOptions {}
            • Modifiers

              • @public

            property cache

            cache?: boolean;

              property ignoreEmptySearchPlaces

              ignoreEmptySearchPlaces?: boolean;

                property packageProp

                packageProp?: string | Array<string>;

                  property searchPlaces

                  searchPlaces?: Array<string>;

                    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 Transform

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

                                                  • @public

                                                type TransformSync

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

                                                  • @public

                                                Package Files (2)

                                                Dependencies (4)

                                                Dev Dependencies (24)

                                                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>