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

optimist-config-file

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

optimist-config-file

Extends optimist with support for JSON/YAML config file Edit

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
39
increased by56%
Maintainers
1
Weekly downloads
 
Created
Source

optimist-config-file npm version Build Status

Extends optimist npm module with support for JSON/YAML config file and Docker's inspired environment variables handling.

How to use it

Refer to examples/example.js

npm install --save optimist-config-file
const program = require('optimist-config-file');

program
	.usage('...')
	// ...
	.describe('config', 'uses JSON or YAML-formatted config file to set parameters').string('config');

// handle --config option for passing YAML/JSON config files
program.setConfigFile('config');

// allow env variables to be passed
program.setReplacementVars(process.env);

// parse options
const options = program.parse(process.argv);

console.log(options);

Example

YAML config file:

banner: Hello, ${USERNAME}! Greetings from ${HOSTNAME:-The Unknown Machine}.

Invocations with environment variables and options:

./example.js  --config config.yaml
Hello, macbre! Greetings from The Unknown Machine.

HOSTNAME=`hostname` ./example.js  --config config.yaml
Hello, macbre! Greetings from debian.

./example.js  --config config.yaml --banner='foo'
Hello, macbre! Greetings from The Unknown Machine.

As you can see config file values have precedence over command line ones.

Keywords

FAQs

Package last updated on 21 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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