New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

config-load

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

config-load

Load config from a tree of JS/JSON files

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

config-load.js

Load config from a tree of JS/JSON files

Current status

NPM version Build Status Dependency Status Dev dependency Status Coverage Status

Usage

Installation

npm install config-load

Loading

var configLoad = require('config-load');

configLoad([path] [, options])

Loads all JS/JSON config files under path, recursively gathering them from the tree structure.

Uses require-folder-tree - see docs for that for explanation of how files are loaded.

If path is not provided, defaults to process.cwd() + '/config'.

Options

env

Environment type - creates a selector (see below).

Defaults to process.env.NODE_ENV || 'development'

selectors

Object determining what parts of the config object to switch dependent on selectors provided.

Defaults to { env: options.env }

Example

If config file parsing produces:

{
    db: {
        server: 'localhost',
        database: 'myDB'
    },
    env: {
        development: {
            db: {
                password: 'dev db password'
            }
        },
        production: {
            db: {
                password: 'production db password'
            }
        }
    },
    otherSetting: 'foo'
}

Then calling:

configLoad(path, { selectors: { env: 'development' } } )

returns:

{
    db: {
        server: 'localhost',
        database: 'myDB',
        password: 'dev db password'
    },
    otherSetting: 'foo'
}
null value

If a selector's value is null, it takes the name key only.

If config file parsing produces:

{
    url: 'http://example.com/',
    local: {
        url: 'http://mysite.com/'
    }
}
configLoad(path, { selectors: { local: null } } )

returns:

{
    url: 'http://mysite.com/'
}

Tests

Use npm test to run the tests. Use npm run cover to check coverage.

Changelog

See changelog.md

Issues

If you discover a bug, please raise an issue on Github. https://github.com/overlookmotel/config-load/issues

Contribution

Pull requests are very welcome. Please:

  • ensure all tests pass before submitting PR
  • add an entry to changelog
  • add tests for new features
  • document new functionality/API additions in README

Keywords

FAQs

Package last updated on 19 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc