0.1.1 • Published 10 years ago

tangle-config v0.1.1

Weekly downloads
1
License
-
Repository
-
Last release
10 years ago

tangle-config

Configuration management for tangle

Strider Build Status Travis Build Status Dependency Status devDependency Status Gittip

NPM

Overview

tangle is a set of tools for building web applications.

tangle-config implements the config subcommand for tangle.

Usage

--key, -k [String] - A configuration key to operate on. If --value is not
                     set, the current value will be written to STDOUT. Keys
                     are namespaced and delimited by ':'.

--value, -v [String] - Save a new value to the specified key.

--file, -f [Path] - Explicitely specify the configFile to operate on. If
                    not set, $HOME/.tangle will be used.

--edit, -e - Manually edit configuration with $EDITOR

--help, -h - Display this message

Examples

# Set your Github username
$ tangle-config -k github:username -v 'yourname'

# Print the current Github username to STDOUT
$ tangle-config -k github:username

# Edit configuration using a text editor
$ tangle-config --edit

API

You can (and should!) use this interface to manage user configuration within your own tangle plugins.

config = require 'tangle-config'

# Reading the global defaults
config.defaults

# Getting the current config file path
config.configFile()

# Retrieving the nconf object
nconf = config.getConf()

# Getting a value
nconf.get 'namespace:key'

The nconf object returned using configFile() has already loaded the config file, env overrides, and the global defaults (in that order of precedence).

The default config file is ~/.tangle, which can be changed by setting the environment variable tangle_config=PATH

See nconf for further documentation.

Project Files

You can use project files to store non-global configuration in a file called tangle.json at the current directory.

config = require 'tangle-config'

# Get a `tangle.json` file in the current working directory
projectFile = config.projectFile()

# Retrieving the nconf object
project = config.getProject()

# Getting a value
project.get 'namespace:key'

# Setting a value
project.set 'namespace:key', value

# Saving the file
project.save (err) ->
  fs.readFile projectFile, (err, data) -> console.error err if err

Contributing

The test suite is implemented with nodeunit and nixt.

To rebuild & run the tests

$ mkdir tanglejs
$ cd tanglejs
$ git clone https://github.com/tanglejs/config.git
$ cd config
$ npm install
$ grunt test

You can use grunt watch to automatically rebuild and run the test suite when files are changed.

Use npm link from the project directory to tell tangle-config to use your modified tangle-config during development.

To contribute back, fork the repo and open a pull request with your changes.

License

Copyright (c) 2014 Logan Koester Licensed under the MIT license.