Permalink
Browse files

Caps insenitivity on env name

  • Loading branch information...
1 parent 3c0ecd6 commit c226271ab99ff7b2a1c92978bc5f2391e58a78c6 @Qard committed Dec 13, 2011
Showing with 10 additions and 17 deletions.
  1. +5 −14 index.js
  2. +5 −3 package.json
View
@@ -4,18 +4,9 @@
* TODO: Support subdirectories
*/
// Load dependencies.
-var p = require('path'), fs = require('fs')
-
-// Adds dot-path location to ordinary objects.
-function Obj (o) {
- for (var p in o) {
- this[p] = (typeof o[p] === 'object') ? new Obj(o[p]) : o[p]
- }
-}
-Obj.prototype.get = function (p) {
- var o = p.split('.').reduce(function (obj, i) { return obj[i] }, this)
- return (typeof o === 'object') ? new Obj(o) : o
-}
+var p = require('path')
+ , fs = require('fs')
+ , DotPath = require('dotpath')
// Copy after() from underscore,
// since we don't need anything else.
@@ -65,7 +56,7 @@ var jsonfig = {
function finish (err, o) {
attempt = noop
if (err) return cb(err)
- cb(null, new Obj(o))
+ cb(null, new DotPath(o))
}
// Start loading files.
@@ -87,7 +78,7 @@ var jsonfig = {
// Parse and insert env data or whole structure into obj.
var json = JSON.parse(data)
- obj[p.basename(file, '.json')] = json[self.env()] || json
+ obj[p.basename(file, '.json')] = json[self.env().toLowerCase()] || json
attempt()
})
View
@@ -2,13 +2,15 @@
"author": "Stephen Belanger <admin@stephenbelanger.com> (http://stephenbelanger.com)",
"name": "jsonfig",
"description": "Simple json config folder manager",
- "version": "0.0.0",
+ "version": "0.0.2",
"repository": {
"url": "git://github.com/Qard/jsonfig.git"
},
"engines": {
- "node": "~v0.4.11"
+ "node": "~v0.4.0"
+ },
+ "dependencies": {
+ "dotpath":"*"
},
- "dependencies": {},
"devDependencies": {}
}

0 comments on commit c226271

Please sign in to comment.