cosmiconfig

  • Version 7.0.1
  • Published
  • 90.9 kB
  • 5 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, or CommonJS module

Index

Variables

variable defaultLoaders

const defaultLoaders: Readonly<{
readonly '.cjs': LoaderSync;
readonly '.js': LoaderSync;
readonly '.json': LoaderSync;
readonly '.yaml': LoaderSync;
readonly '.yml': LoaderSync;
readonly noExt: LoaderSync;
}>;

    Functions

    function cosmiconfig

    cosmiconfig: (
    moduleName: string,
    options?: Options
    ) => {
    readonly search: (searchFrom?: string) => Promise<CosmiconfigResult>;
    readonly load: (filepath: string) => Promise<CosmiconfigResult>;
    readonly clearLoadCache: () => void;
    readonly clearSearchCache: () => void;
    readonly clearCaches: () => void;
    };

      function cosmiconfigSync

      cosmiconfigSync: (
      moduleName: string,
      options?: OptionsSync
      ) => {
      readonly search: (searchFrom?: string) => CosmiconfigResult;
      readonly load: (filepath: string) => CosmiconfigResult;
      readonly clearLoadCache: () => void;
      readonly clearSearchCache: () => void;
      readonly clearCaches: () => void;
      };

        Interfaces

        interface Options

        interface Options extends OptionsBase {}

          property loaders

          loaders?: Loaders;

            property transform

            transform?: Transform;

              interface OptionsSync

              interface OptionsSync extends OptionsBase {}

                property loaders

                loaders?: LoadersSync;

                  property transform

                  transform?: TransformSync;

                    Type Aliases

                    type Loader

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

                      type LoaderSync

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

                        type Transform

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

                          type TransformSync

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

                            Package Files (1)

                            Dependencies (5)

                            Dev Dependencies (25)

                            Peer Dependencies (0)

                            No peer dependencies.

                            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>