Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

confortable

clux57MIT1.0.0

Finds the right recursively placed config file

config, finder, recursive, comfortable, nottypo

readme

Confortable

npm status build status dependency status coverage status

Confortable is a lightweight config file locator. It will look at the execution cwd, and if no config matching the name is found, and the cwd is inside $HOME, it will keep going up one directory until it hits $HOME. Example usage can be seen in logule. and combustion.

It does not parse the config, and thus does not enforce any structure upon the config file itself. It simply returns the best existing path || null.

Usage

Basic usage:

var conf = require('confortable');
confPath = conf('.confName'); // if non-null, this can be read by fs or required if js compatible

Optionally, a start directory (if cwd isn't sufficient) can be specified for the search start:

var confPath = require('confortable')('.combustion', templateDir);

A final optional setting is a fallback directory, in case the recursive search fails, but you still want to see if a config exists somewhere else (like say the path of the parent module). In this use case, you have to specify the start as well.

var fallback = require('path').dirname(module.parent.filename);
var confPath = require('confortable')('.logule', process.cwd(), fallback);

Installation

$ npm install confortable

License

MIT-Licensed. See LICENSE file for details.

changelog

1.0.0 / 2015-11-15

  • Added npmignore
  • No other changes - just should be indicated as stable

0.2.2 / 2014-07-22

  • Documentation and coverage release.

0.2.1 / 2013-04-10

  • Better windows support by using env.HOMEDIR and env.HOMEDRIVE (thanks agsh)

0.2.0 / 2012-10-26

  • Neaten up code + more tests
  • Change no-found config from null to undefined
  • remove node 0.6 support

0.1.5 / 2012-07-20

  • Search for configs in HOME even if start directory is outside it.

0.1.4 / 2012-07-17

  • Fixed a bug with fallback dir overriding cwd search

0.1.3 / 2012-07-18

  • Allow a fallback directory to be scanned if original search fails
  • Improve search corner cases (particularly for windows)

0.1.2 / 2012-07-14

  • Fix scanning algorithm for windows directories

0.1.1 / 2012-07-13

  • Allow custom start directory

0.1.0 / 2012-07-03

  • First proper version