Skip to content

Instantly share code, notes, and snippets.

@dweinstein
Last active June 10, 2016 14:41
Show Gist options
  • Save dweinstein/8e7e7dfd57dae35367b9adc7de774066 to your computer and use it in GitHub Desktop.
Save dweinstein/8e7e7dfd57dae35367b9adc7de774066 to your computer and use it in GitHub Desktop.
configuration / CLI options via RC or env node.js
// config.js
const config = require('rc')('setupios', {
  default: 'value',
  other: {
     thing: 'blah'
  }
});
module.exports = config;
// index.js
'use strict';

const cfg = require('./config');

console.log(cfg);

which allows overriding the config via ENV and CLI as well:

node index.js --default foo --other.value ok

and

setupios_default=foo setupios_thing__blah=blah2 node index.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment