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

wild-config

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wild-config - npm Package Compare versions

Comparing version 1.5.1 to 1.6.0

5

.prettierrc.js
module.exports = {
printWidth: 160,
tabWidth: 4,
singleQuote: true
singleQuote: true,
endOfLine: 'lf',
trailingComma: 'none',
arrowParens: 'avoid'
};

16

index.js

@@ -14,2 +14,3 @@ /* eslint no-console: 0, global-require: 0 */

.replace(/[^0-9a-z-_]/g, '') || 'development';
const fs = require('fs');

@@ -24,3 +25,16 @@ const glob = require('glob');

const argv = require('minimist')(process.argv.slice(2));
const argList = process.argv.slice(2);
// Populate environment variables into cli arguments
// appconf_key_name=123 becomes --key.name=123
Object.keys(process.env).forEach(key => {
if (/^appconf_/i.test(key)) {
let cKey = key.substr('appconf_'.length).replace(/_/g, '.');
if (!argList.some(e => e.indexOf(`--${cKey}=`) >= 0)) {
argList.push(`--${cKey}=${process.env[key]}`);
}
}
});
const argv = require('minimist')(argList);
const configPath = process.env.NODE_CONFIG_PATH || argv.config || false;

@@ -27,0 +41,0 @@

{
"name": "wild-config",
"version": "1.5.1",
"version": "1.6.0",
"description": "Configuration management module",

@@ -11,3 +11,3 @@ "main": "index.js",

"type": "git",
"url": "git+https://github.com/wildduck-email/wild-config.git"
"url": "git+https://github.com/nodemailer/wild-config.git"
},

@@ -20,8 +20,8 @@ "keywords": [

"bugs": {
"url": "https://github.com/wildduck-email/wild-config/issues"
"url": "https://github.com/nodemailer/wild-config/issues"
},
"homepage": "https://github.com/wildduck-email/wild-config#readme",
"homepage": "https://github.com/nodemailer/wild-config#readme",
"dependencies": {
"deep-extend": "0.6.0",
"glob": "7.1.6",
"glob": "7.2.0",
"minimist": "1.2.5",

@@ -32,7 +32,7 @@ "toml": "3.0.0"

"eslint-config-nodemailer": "1.2.0",
"eslint-config-prettier": "6.11.0",
"grunt": "1.1.0",
"grunt-cli": "1.3.2",
"grunt-eslint": "22.0.0"
"eslint-config-prettier": "8.4.0",
"grunt": "1.4.1",
"grunt-cli": "1.4.3",
"grunt-eslint": "24.0.0"
}
}

@@ -8,4 +8,4 @@ # wild-config

- The application can have a config file for default values in ./config/default.toml
- Main config file path can be provided from a command line argument, eg. `--config=/etc/app.toml`
- Additionally command line arguments can be used to override any existing config option
- Main config file path can be provided from a command-line argument, e.g. `--config=/etc/app.toml`
- Additionally, command-line arguments can be used to override any existing config option
- _wild-config_ detects SIGHUP and reloads configuration files automatically

@@ -20,9 +20,37 @@

3. `NODE_CONFIG_PATH` environment value or `--config` argument value
4. command line arguments
4. `APPCONF_*` prefixed environment variables
5. command line arguments
> If you want to use a different configuration directory than './config' for default configuration files, then set it with the `NODE_CONFIG_DIR` environment variable
### Environment variables
When using environment variables to provide config values, only such keys are merged that already exist in the configuration object, so you have to define a default value in the config file. Use underscores instead of dots for subkeys.
Example _config/default.toml_:
```toml
[server]
apiPort=3000
```
Override `server.apiPort` value with the following environment variable:
```
APPCONF_server_apiPort=80
```
This resolves into the following config structure:
```
{
server: {
apiPort: 80
}
}
```
### Command line arguments
When using command line arguments to provide config values only such keys are merged that already exist in the configuration object. For subkeys use dot notation. Value type (numbers, booleans and strings are supported) is defined by existing value.
Like with the environment variables, when using command-line arguments to provide config values, only such keys are merged that already exist in the configuration object. For subkeys, use dot notation. Value type (numbers, booleans, and strings are supported) is defined by existing value.

@@ -36,3 +64,3 @@ Example _config/default.toml_:

Override `server.enabled` value with the following command line argument:
Override `server.enabled` value with the following command-line argument:

@@ -43,3 +71,3 @@ ```

`server.enabled` is defined as a boolean in the config file, so the overriden value is also going to be `true` as a boolean and not `"true"` as a string.
`server.enabled` is defined as a boolean in the config file, so the overridden value is also going to be `true` as a boolean and not `"true"` as a string.

@@ -52,3 +80,3 @@ ## TOML extensions

Use the following syntax to include an additional config file in the place of the directive
Use the following syntax to include an additional config file in the place of the directive.

@@ -59,3 +87,3 @@ ```toml

This directive also works in a nested object
This directive also works in a nested object.

@@ -67,3 +95,3 @@ ```toml

You can also use wildcards to load data from multiple files
You can also use wildcards to load data from multiple files.

@@ -78,5 +106,5 @@ ```toml

- Included paths are resolved relative to the path of the configuration file where the include directive is used
- Included config files do not have to be toml files, any other supported format works as well
- If the included config file is a toml file then it can have its own includes
- If the config file returns an array then the array value will become the value of the parent key of the directive only if there are no other subkeys at the same level as the directive
- Included config files do not have to be toml files. Any other supported format works as well
- If the included config file is a toml file, then it can have its own includes
- If the config file returns an array, then the array value will become the value of the parent key of the directive only if there are no other subkeys at the same level as the directive
- Special value `{ENV}` is replaced in all file paths by the NODE_ENV value

@@ -86,3 +114,3 @@

If you are running your app as a service daemon, then you can load configuration from a config file by using the `--config` argument. These values are loaded and merged with the default values.
If you are running your app as a service daemon, you can load configuration from a config file using the `--config` argument. These values are loaded and merged with the default values.

@@ -104,3 +132,3 @@ ```

_wild-config_ catches SIGHUP signal and reloads configuration files. Additionally a 'reload' event is emitted.
_wild-config_ catches SIGHUP signal and reloads configuration files. Additionally, a 'reload' event is emitted.

@@ -116,3 +144,3 @@ ```javascript

- _'reload'_ emitted when SIGHUP is received and configuration is reloaded
- _'reload'_ emitted when SIGHUP is received, and configuration is reloaded

@@ -119,0 +147,0 @@ ### Limitations

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