Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Recursively walks up directories from the current directory to look for settings files to provide defaults for commander.js
JavaScript
branch: master
Failed to load latest commit information.
lib Update Q
test update .end to .done in tests
.gitignore Initial commit
.travis.yml Add travis
README.md Docs
index.js switch .end() to .done() [closes #1]
package.json Release 0.0.4

README.md

Build Status

commander-config

Recursively walks up directories from the current directory to look for settings files to provide defaults for commander.js

If you run your app in /foo/bar/baz/ and use the relative path .boz then commander-config would try:

  • /foo/bar/baz/.boz.json
  • /foo/bar/baz/.boz.yaml
  • /foo/bar/baz/.boz.yml
  • /foo/bar/.boz.json
  • /foo/bar/.boz.yaml
  • /foo/bar/.boz.yml
  • /foo/.boz.json
  • /foo/.boz.yaml
  • /foo/.boz.yml
  • /.boz.json
  • /.boz.yaml
  • /.boz.yml

It will then merge any settings it finds such that the ones at the top of that list override the ones at the bottom.

API

lookUpSettings(relativePath)

Looks up settings relative to the current directory, and relative to each parent directory of the current directory. Child directories take priority over parent directories and the settings are merged in using a shallow merge. The return value is a promise.

var settings = require('comander-config').lookUpSettings('.myCrazyApp');
settings.then(console.log).end();

withSettings(relativePath, cb)

When used with commander this will merge settings into the env parameter of the function.

var program = require('commander');
var config = require('commander-config');
program
  .command('run [name]')
  .action(config.withSettings('.myCrazyApp', function (name, env) {

  }));
Something went wrong with that request. Please try again.