coffee-config
Advanced tools
Comparing version
16
index.js
@@ -12,10 +12,10 @@ // Generated by CoffeeScript 1.6.2 | ||
Configurator.prototype.sync = function(dir) { | ||
return this._loadConfigFileSync(dir); | ||
Configurator.prototype.sync = function() { | ||
return this._loadConfigFileSync(); | ||
}; | ||
Configurator.prototype.async = function(dir, callback) { | ||
Configurator.prototype.async = function(callback) { | ||
var _this = this; | ||
return this._loadConfigFileAsync(dir, function() { | ||
return this._loadConfigFileAsync(function() { | ||
if (callback != null) { | ||
@@ -45,6 +45,6 @@ return callback(); | ||
Configurator.prototype._loadConfigFileSync = function(dir) { | ||
Configurator.prototype._loadConfigFileSync = function() { | ||
var data, json, key, value; | ||
data = fs.readFileSync(dir + '/config.json'); | ||
data = fs.readFileSync(process.cwd() + '/config.json'); | ||
json = JSON.parse(data); | ||
@@ -58,7 +58,7 @@ for (key in json) { | ||
Configurator.prototype._loadConfigFileAsync = function(dir, callback) { | ||
Configurator.prototype._loadConfigFileAsync = function(callback) { | ||
var data, | ||
_this = this; | ||
return data = fs.readFile(dir + '/config.json', function(err, data) { | ||
return data = fs.readFile(process.cwd() + '/config.json', function(err, data) { | ||
var json, key, value; | ||
@@ -65,0 +65,0 @@ |
@@ -6,6 +6,6 @@ { | ||
"author": "Dominik Krejcik <dominik.krejcik@gmail.com>", | ||
"repository": {"type": "git", "url": "git://github.com/dominikkrejcik/configurator.git"}, | ||
"version": "0.1.1", | ||
"repository": {"type": "git", "url": "git://github.com/dominikkrejcik/coffee-config.git"}, | ||
"version": "0.2.0", | ||
"dependencies": { | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
configurator | ||
coffee-config | ||
============ | ||
@@ -7,7 +7,15 @@ | ||
Usage with config.json in project root directory: | ||
`$ npm install coffee-config` | ||
``` coffeescript | ||
config = require 'configurator' | ||
config.async __dirname, -> | ||
config.async -> | ||
port = config.get 'port' | ||
address = config.production.address | ||
# or | ||
config.sync() | ||
port = config.get 'port' | ||
address = config.production.address | ||
``` |
2603
4%21
61.54%