Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

standard-settings

Package Overview
Dependencies
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

standard-settings - npm Package Compare versions

Comparing version 1.1.15 to 1.1.16

.npmignore

6

index.js

@@ -45,4 +45,6 @@ // first settings loaded are stronger than last one

lookUpPaths.push(path.resolve(path.dirname(require.main.filename), path.join('..', '..', '..'))) // inside electron
lookUpPaths.push(path.resolve(path.dirname(require.main.filename), path.join('..', '..', '..', 'app.asar.unpacked'))) // inside electron with asar
if (require.main.filename) {
lookUpPaths.push(path.resolve(path.dirname(require.main.filename), path.join('..', '..', '..'))) // inside electron
lookUpPaths.push(path.resolve(path.dirname(require.main.filename), path.join('..', '..', '..', 'app.asar.unpacked'))) // inside electron with asar
}
lookUpPaths.push(process.execPath)

@@ -49,0 +51,0 @@

{
"name": "standard-settings",
"version": "1.1.15",
"version": "1.1.16",
"description": "Standardised settings loader",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -53,2 +53,36 @@ _**Standard settings** — automatic settings loader_

## Settings Load override order
As per `standard-settings` rules, **environement variable** will always take precedence over keys that could be set by command line argument or via file
1. The `settings.default.json` file which is in `settings` folder of your main app
2. The `settings.json` file which is in `settings` folder of your main app
3. Via a setting file through the command line
Example:
`$ node index.js --settings settings/settings.prod.json` to specify a settings file wich will override `server.port`
3. Via command line parameters (argv)
Example:
`$ node index.js --server.port 2000` to specify a field
This means that if you pass a `settings` file with `--settings` argument, the target key will override the value in the settings.
5. ### Environment variables
Example:
`$ SERVER_PORT=2500 node index.js`
`$ service_spacebro_inputMessage=new-media node index.js`
`$SERVER_PORT=6666 node examples/index.js --settings ./settings/settings.production.json --server.port 2000`
Here, the `SERVER_PORT` env will always win. You'll endup with a 6666 value for the key `port`of the key `server`
This means that if you pass a `settings` file with `--settings` argument, or a target key with command line like `--server.port` the environment variable will be the final value.
## 👋 Usage inside Node.js or Electron

@@ -78,3 +112,3 @@

### getSettings()
- **returns**: full settings (JSON Object)
- **returns**: full settings, environement included (JSON Object)
- **description**: This function creates a new object resulting from the overload of the `settings` (from settings.default) with the `settings` value (from settings.json) and returns its content.

@@ -92,17 +126,2 @@

## Load priority order
### Environment variables
Example:
`$ SERVER_PORT=2500 node index.js`
`$ service_spacebro_inputMessage=new-media node index.js`
### Command line parameters (argv)
Example:
`$ node index.js --server.port 2000` to specify a field
`$ node index.js --settings settings/settings.prod.json` to specify a settings file
## Working all together with different settings

@@ -109,0 +128,0 @@

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