Skip to content

Find and load a configuration object. based on cosmiconfig

Notifications You must be signed in to change notification settings

allex/config-finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

config-finder

Find and load a configuration object. based on cosmiconfig

Installation

npm i config-finder

Features

  • Support functionaly evaluation with customize context.
  • Mixin multiple externals by extends property.

Usage

// cat package.json
{
  ...

  "fss": {
    "extends": [
      "./.fssrc.js"
    ],
    "foo": [ "bar" ]
  }
}

// cat ./.fssrc.js
module.exports = (ctx) => {
  return Object.assign({}, ctx,
    {
      rollup: { /* input, output */ }
    }
}
const configFinder = require('config-finder')
const yourModuleName = 'fss'
const modConfig = configFinder(yourModuleName)

const cfg = modConfig(ctx[, path, options])
  .then((result) => {
    // result.config is the parsed configuration object
    // result.filepath is the path to the config file that was found
  })
  .catch((parsingError) => {
    // do something constructive
  });

// sync mode
// const cfg = modConfig.sync(ctx[, path, options])

License

MIT

About

Find and load a configuration object. based on cosmiconfig

Resources

Stars

Watchers

Forks

Packages

No packages published