🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

oniyi-config

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oniyi-config

Simple config file loader

latest
Source
npmnpm
Version
1.1.2
Version published
Maintainers
1
Created
Source

oniyi-config NPM version Dependency Status

Simple config file loader

Installation

$ npm install --save oniyi-config

Usage

const oniyiConfig = require('oniyi-config');

const cfg = oniyiConfig({
  sourceDir: __dirname,
  baseName: 'providers',
  environment: 'production',
  });

will merge jsand json files starting with name providers in __dirname iteratively. File name schema is providers.[environment].(json|js).

environment is optional and defaults to development. Possible values are anything you can set in process.env.NODE_ENV. For file name resolution, process.env.NODE_ENV will be transformed to lower-case.

One special environment is local. It will always be loaded last. You can provide the same file name with different extensions. json will always be loaded before js, meaning js will overwrite json

Sample load order:

  • providers.json
  • providers.js
  • providers.development.json
  • providers.development.js
  • providers.local.json
  • providers.local.js

Options

  • sourceDir, baseDir, basePath: single directory path to load config files from
  • sourceDirs: array of directory paths to load config files from. Files are loaded in preceding order (meaning the last one is loaded first extended with _.mergeWith() in reverse order; as customizer for _.mergeWith(), a custom function from lib/utils.js is used)
  • baseName: the baseName for config files (e.g. providers from the example above)
  • env, environment: the environment part of config file names (e.g. development from the example above) Note: local is always added / loaded

License

MIT © Benjamin Kroeger

Keywords

oniyi

FAQs

Package last updated on 08 Apr 2019

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