Comparing version 0.2.7 to 0.2.8
@@ -9,5 +9,6 @@ "use strict"; | ||
version: package_json.version, | ||
environment: process.env.NODE_ENV || "development", | ||
keys_and_values: {}, | ||
environment: function() { | ||
return process.env.NODE_ENV || dotenv.keys_and_values["NODE_ENV"] || "development" | ||
}, | ||
_loadEnv: function() { | ||
@@ -17,3 +18,3 @@ return dotenv._getKeysAndValuesFromEnvFilePath(".env"); | ||
_loadEnvDotEnvironment: function() { | ||
return dotenv._getKeysAndValuesFromEnvFilePath(".env."+dotenv.environment); | ||
return dotenv._getKeysAndValuesFromEnvFilePath(".env."+dotenv.environment()); | ||
}, | ||
@@ -20,0 +21,0 @@ _getKeyAndValueFromLine: function(line) { |
{ | ||
"name": "dotenv", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"description": "Loads environment variables from .env", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
@@ -23,3 +23,3 @@ # dotenv | ||
... | ||
"dotenv": "0.2.7" | ||
"dotenv": "0.2.8" | ||
} | ||
@@ -26,0 +26,0 @@ } |
@@ -14,3 +14,3 @@ var assert = require('assert'), | ||
it('version should be set', function() { | ||
result.version.should.eql("0.2.7"); | ||
result.version.should.eql("0.2.8"); | ||
}); | ||
@@ -45,8 +45,8 @@ | ||
it('reads from .env.development', function() { | ||
process.env.FROM_DEVELOPMENT_ENV.should.eql("from_development_env"); | ||
it('reads from .env.staging', function() { | ||
process.env.FROM_STAGING_ENV.should.eql("from_staging_env"); | ||
}); | ||
it('overrides any values in .env with .env.environment', function() { | ||
process.env.ENVIRONMENT_OVERRIDE.should.eql("development"); | ||
process.env.ENVIRONMENT_OVERRIDE.should.eql("staging"); | ||
}); | ||
@@ -80,5 +80,31 @@ | ||
process.env.ENVIRONMENT_OVERRIDE.should.eql("set_on_machine"); | ||
delete process.env.ENVIRONMENT_OVERRIDE; //clean up for other tests | ||
}); | ||
}); | ||
describe('.load() if NODE_ENV is set in .env', function() { | ||
before(function() { | ||
result.load(); | ||
}); | ||
it('ENVIRONMENT_OVERRIDE should equal the value set in the .env.staging', function() { | ||
process.env.ENVIRONMENT_OVERRIDE.should.eql('staging'); | ||
delete process.env.NODE_ENV; //cleanup for other tests | ||
delete process.env.ENVIRONMENT_OVERRIDE; | ||
}); | ||
}); | ||
describe('.load() if NODE_ENV is set in .env but NODE_ENV is already set on machine', function() { | ||
before(function() { | ||
process.env.NODE_ENV = "development" | ||
result.load(); | ||
}); | ||
it('ENVIRONMENT_OVERRIDE should equal the value set in the .env.development because that is the environment being set by the machine. machine wins here.', function() { | ||
process.env.ENVIRONMENT_OVERRIDE.should.eql('development'); | ||
delete process.env.NODE_ENV; //clean up for other tests | ||
delete process.env.ENVIRONMENT_OVERRIDE; | ||
}); | ||
}); | ||
describe('.parse()', function(){ | ||
@@ -85,0 +111,0 @@ it('should return an object', function(){ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
11319
10
182
28