Permalink
Browse files

[bump] Fix node 0.6 support.

  • Loading branch information...
1 parent be94c3d commit f0705494566891a3f73544ca0faf92e4bd86e4f0 @brianloveswords committed Oct 19, 2012
Showing with 13 additions and 3 deletions.
  1. +12 −2 index.js
  2. +1 −1 package.json
View
@@ -1,4 +1,5 @@
var fs = require('fs');
+var pathutil = require('path');
function habitat(prefix, defaults) {
if (!(this instanceof habitat))
@@ -193,7 +194,7 @@ habitat.get = function get() {
habitat.load = function load(path) {
path = path || '.env';
- if (!fs.existsSync(path))
+ if (!fileExists(path))
return false;
var exports = fs.readFileSync(path).toString().split('\n');
exports.map(function (param) {
@@ -230,6 +231,15 @@ function fromCamelCase(input) {
return input.replace(expression, function (_, lower, upper) {
return lower + '_' + upper.toLowerCase();
});
-};
+}
+
+/**
+ * Check file existence.
+ * For supporting both node 0.6 and node 0.8
+ */
+
+function fileExists(path) {
+ return (fs.existsSync || pathutil.existsSync)(path);
+}
module.exports = habitat;
View
@@ -1,6 +1,6 @@
{
"name": "habitat",
- "version": "0.3.1",
+ "version": "0.3.2",
"description": "Small library for managing environment variables",
"main": "index.js",
"directories": {

0 comments on commit f070549

Please sign in to comment.