Comparing version 0.2.3 to 0.2.4
@@ -19,6 +19,9 @@ "use strict"; | ||
_getKeyAndValueFromLine: function(line) { | ||
var key_value_array = line.match(/^\s*([\w\.\-\_]+)\s*=\s*(.*?)\s*$/); | ||
var key = key_value_array[1].trim(); | ||
var value = key_value_array[2].trim(); | ||
var key_value_array = line.match(/^\s*([\w\.\-]+)\s*=\s*(.*)?\s*$/); | ||
if (!key_value_array) return null; | ||
var key = key_value_array[1]; | ||
var value = key_value_array[2]; | ||
if (value.charAt(0) === '"' && value.charAt(value.length-1) == '"') { | ||
@@ -32,3 +35,4 @@ value = value.replace(/\\n/gm, "\n"); | ||
_getKeysAndValuesFromEnvFilePath: function(filepath) { | ||
var data, content, lines; | ||
var data, content, lines, keys_and_values; | ||
try { | ||
@@ -43,14 +47,12 @@ data = fs.readFileSync(filepath); | ||
for (var i=0; i<lines.length; i++) { | ||
try { | ||
var array = dotenv._getKeyAndValueFromLine(lines[i]); | ||
var key = array[0]; | ||
var value = array[1]; | ||
keys_and_values = lines.map(dotenv._getKeyAndValueFromLine) | ||
.filter(Array.isArray); | ||
keys_and_values.forEach(function(pair) { | ||
var key = pair[0]; | ||
var value = pair[1]; | ||
dotenv.keys_and_values[key] = value; | ||
} catch (e) { | ||
} | ||
}) | ||
} | ||
return true; | ||
@@ -57,0 +59,0 @@ }, |
{ | ||
"name": "dotenv", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Loads environment variables from .env", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
@@ -23,3 +23,3 @@ # dotenv | ||
IMPORTANT: In pre `0.2.3`, you instantiated dotenv like the following with the bagels. | ||
IMPORTANT: In pre `0.2.0`, you instantiated dotenv like the following with the bagels. | ||
@@ -26,0 +26,0 @@ ```javascript |
@@ -13,3 +13,3 @@ var assert = require('assert'), | ||
it('version should be set', function() { | ||
result.version.should.eql("0.2.3"); | ||
result.version.should.eql("0.2.4"); | ||
}); | ||
@@ -16,0 +16,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7518
115