1.0.1 • Published 6 years ago

@copropr/config-plugin v1.0.1

Weekly downloads
2
License
ISC
Repository
-
Last release
6 years ago

Config Plugin

This plugin lets you load yml files as configs in your projects

Installation

# NPM
$ npm i -S @copropr/config-plugin

# Yarn
$ yarn add @copropr/config-plugin

Usage

// Commonjs
const ConfigPlugin = require('@copropr/config-plugin').default

// ES6 module way
import ConfigPlugin from '@copropr/config-plugin'

const conf = new ConfigPlugin([
  'path/to/your/config.yml'
])

The constructor expect an array of path string or object containing:

  • path: string The path of the file relative to project root
  • throw: boolean If it should throw an exception in case the file is not found

The files will be loaded in the order you set, so the second file will always overwrite the first, and so on...

*Note: Don't forget to use .default if using es5 modules*

API

get method

The get method is a proxy to the lodash get function without specifying the object

example:

conf.get('var1.nestedvar', defaultValue)

wholeConfig (getter)

This getter will return the whole config object

example:

const configObject = conf.wholeConfig
1.0.1

6 years ago

1.0.0

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago