Comparing version 1.0.2 to 2.0.0
@@ -18,3 +18,2 @@ 'use strict'; | ||
const optionProperties = schema[optionName]; | ||
const envVarname = optionProperties.envVariableName; | ||
const type = Object.prototype.hasOwnProperty.call(optionProperties, 'type') ? optionProperties.type : 'string'; | ||
@@ -27,4 +26,4 @@ const parser = parsers.get(type); | ||
if (envNames.includes(envVarname)) { | ||
config.set(optionName, parse(env[envVarname], parser)); | ||
if (envNames.includes(optionName)) { | ||
config.set(optionName, parse(env[optionName], parser)); | ||
} else if (!optionProperties.required) { | ||
@@ -31,0 +30,0 @@ config.set(optionName, parse(optionProperties.defaultValue, parser)); |
{ | ||
"name": "configeur", | ||
"version": "1.0.2", | ||
"version": "2.0.0", | ||
"description": "Extensible parsing of environment variables into config.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -29,5 +29,4 @@ # configeur | ||
const config = configeur({ | ||
port: { | ||
PORT: { | ||
defaultValue: '8000', | ||
envVariableName: 'PORT', | ||
type: 'number' | ||
@@ -41,3 +40,3 @@ } | ||
The above, assuming no values are read from the environment, will assign | ||
config.js a `Map` instance with one key `port` with a value of `8000`. | ||
config.js a `Map` instance with one key `PORT` with a value of `8000`. | ||
@@ -48,3 +47,2 @@ Fields used to configure a config variable are: | ||
| ------------------- | -------- | ----------- | | ||
| `'envVariableName'` | `true` | The name of the environment variable to parse. Overrides the default. | ||
| `'defaultValue'` | `false` | The value used when the variable is not found in the environment. Must always be a string, as if it has come from the environment. | | ||
@@ -51,0 +49,0 @@ | `'required'` | `false` | Defaults to false. When true, a corresponding environment variable is required. A default will be ignored and an error thrown when the environment variable is not found. |
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
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
6442
60
74