configs-overload
Advanced tools
Comparing version 0.1.2 to 0.1.3
12
index.js
@@ -26,5 +26,11 @@ 'use strict'; | ||
* @param {String} directory | ||
* @param {String} defaultEnv | ||
* @param {String} environment | ||
* @returns {*} config | ||
*/ | ||
var loadDirectory = function (directory, defaultEnv, environment) { | ||
directory = directory || path.join(process.cwd(), 'configs'); | ||
defaultEnv = defaultEnv || 'default'; | ||
environment = environment || defaultEnv; | ||
var config = Object.create({}, /** @lends config */ { | ||
@@ -85,9 +91,9 @@ extend: { | ||
module.exports = function (configsDirectory, options) { | ||
configsDirectory = configsDirectory || process.env.NODE_CONFIG_DIR || path.join(process.cwd(), 'configs'); | ||
configsDirectory = configsDirectory || process.env.NODE_CONFIG_DIR; | ||
options = options || {}; | ||
options.defaultEnv = options.defaultEnv || process.env.NODE_DEFAULT_ENV || 'default'; | ||
options.env = options.env || process.env.NODE_ENV || options.defaultEnv; | ||
options.defaultEnv = options.defaultEnv || process.env.NODE_DEFAULT_ENV; | ||
options.env = options.env || process.env.NODE_ENV; | ||
return loadDirectory(configsDirectory, options.defaultEnv, options.env); | ||
}; |
{ | ||
"name": "configs-overload", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Load configs with ease", | ||
"main": "index.js", | ||
"directories": { | ||
"test": "tests" | ||
}, | ||
"scripts": { | ||
"test": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- --recursive tests/test.*.js -R spec" | ||
"test": "jshint . && jscs . && mocha -R spec", | ||
"coverage": "istanbul cover node_modules/.bin/_mocha --report html -- -R spec", | ||
"coveralls": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls" | ||
}, | ||
@@ -33,5 +31,9 @@ "repository": { | ||
"devDependencies": { | ||
"chai": "~1.9.0", | ||
"mocha": "~1.17.1", | ||
"istanbul": "~0.2.6" | ||
"mocha": "~1.17.0", | ||
"mocha-lcov-reporter": "~0.0.1", | ||
"coveralls": "~2.8.0", | ||
"istanbul": "~0.2.3", | ||
"jshint": "~2.4.4", | ||
"jscs": "~1.3.0", | ||
"chai": "~1.9.0" | ||
}, | ||
@@ -38,0 +40,0 @@ "dependencies": { |
@@ -1,4 +0,8 @@ | ||
# configs-overload [![Build Status](https://travis-ci.org/floatdrop/configs-overload.png?branch=master)](https://travis-ci.org/floatdrop/configs-overload) | ||
# configs-overload | ||
[![NPM Version](https://badge.fury.io/js/configs-overload.png)](https://npmjs.org/package/configs-overload) [![Build Status](https://travis-ci.org/floatdrop/configs-overload.png?branch=master)](https://travis-ci.org/floatdrop/configs-overload) [![Coverage Status](https://coveralls.io/repos/floatdrop/configs-overload/badge.png?branch=master)](https://coveralls.io/r/floatdrop/configs-overload) [![Dependency Status](https://gemnasium.com/floatdrop/configs-overload.png)](https://gemnasium.com/floatdrop/configs-overload) | ||
> Load configs with ease | ||
This package helps you to organize your configurations and load them on per-environment basis. Also it have default file, which reduce amount of repetative key-value pairs between configuration files. | ||
## Installation | ||
@@ -26,6 +30,6 @@ | ||
```js | ||
var config = require('configs-overload')('/configs', { env: 'production' }); | ||
var config = require('configs-overload')('./configs', { env: 'production' }); | ||
``` | ||
`configs-overoload` will load configs from `default.js` and extend them with object loaded `production.js`. | ||
`configs-overoload` will load configs from `default.js` and extend them with object loaded from `production.js`. | ||
@@ -46,4 +50,4 @@ ## API | ||
* `defaultEnv` - name of default environment, which will be overloaded with current environment (default: `default`) | ||
* `env` - Environment name which will override `defaultEnv`. | ||
* `defaultEnv` - name of default environment, which will be overloaded with current environment (default: `process.env.NODE_DEFAULT_ENV` or `default`) | ||
* `env` - Environment name which will override `defaultEnv` (default: `process.env.NODE_ENV` or `defaultEnv`). | ||
@@ -65,3 +69,24 @@ ## Environment variables | ||
MIT | ||
The MIT License (MIT) | ||
Copyright (c) 2014 Vsevolod Strukchinsky and other [contributors](https://github.com/floatdrop/configs-overload/blob/master/CONTRIBUTORS.md) | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90
6
10036
7
10
118
1