New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

envcfg

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

envcfg - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

20

lib/envcfg.js

@@ -16,3 +16,3 @@

* Create a config into an environment aware one.
*
*
* @param {String|Object} config

@@ -26,7 +26,7 @@ * @return {Object}

return Object.freeze(new Config(config));
};
}
/**
* Reads the `file`. Handles json and modules.
*
*
* @param {String} file

@@ -44,3 +44,3 @@ * @return {Object}

* Shallow copies `obj`.
*
*
* @param {Object} obj

@@ -62,3 +62,3 @@ * @return {Object}

* Extend object `a` with object `b`.
*
*
* @param {Object} a

@@ -87,3 +87,3 @@ * @param {Object} b

* Config constructor.
*
*
* @param {Object}

@@ -95,3 +95,3 @@ * @api public

var env = process.env.NODE_ENV || 'development';
var settings = copy(cfg[env]) || {};
var settings = copy(cfg[env]) || cfg;
var common = cfg['*'];

@@ -105,4 +105,4 @@ var descriptors = {

if (common) {
extend(settings, common);
}
extend(settings, common);
}

@@ -118,5 +118,5 @@ Object.defineProperty(this, 'env', extend({

}, descriptors));
}, this);
}, this);
}

@@ -5,3 +5,3 @@ {

"description": "stupid simple environment aware configuration",
"version": "0.0.2",
"version": "0.0.3",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

@@ -24,3 +24,3 @@ [![Build Status](https://secure.travis-ci.org/gjohnson/envcfg.png?branch=master)](http://travis-ci.org/gjohnson/envcfg)

Files can be loaded by passing the path to file that follows the structure above. If the file ends in `.json` it will be assumed it is a JSON file and will be parsed accordingly.
Files can be loaded by passing the path to file that follows the structure above. If the file ends in `.json` it will be assumed it is a JSON file and will be parsed accordingly.

@@ -27,0 +27,0 @@ ```javascript

@@ -5,3 +5,3 @@ 'use strict';

var path = require('path');
var should = require('should');
var assert = require('assert');

@@ -15,3 +15,3 @@ describe('envcfg', function() {

var config = envcfg(path.join(__dirname + '/fixtures/basic.json'));
config.should.be.instanceof(envcfg.Config);
assert(config instanceof envcfg.Config);
});

@@ -21,3 +21,3 @@

var config = envcfg(path.join(__dirname + '/fixtures/basic'));
config.should.be.instanceof(envcfg.Config);
assert(config instanceof envcfg.Config);
});

@@ -29,3 +29,3 @@ });

var config = envcfg(require(path.join(__dirname + '/fixtures/basic')));
config.should.be.instanceof(envcfg.Config);
assert(config instanceof envcfg.Config);
});

@@ -36,3 +36,3 @@ });

it('should expose the detected environment', function() {
config.env.should.equal(process.env.NODE_ENV);
assert.equal(config.env, process.env.NODE_ENV);
});

@@ -42,3 +42,3 @@

var enumerable = Object.getOwnPropertyDescriptor(config, 'env').enumerable;
enumerable.should.not.be.true;
assert(enumerable === false);
});

@@ -49,26 +49,26 @@ });

it('should provide the setting value based on environment', function() {
config.foo.should.equal('foo-test');
config.bar.should.equal('bar-test');
config.buz.should.equal('buzz-*');
assert.equal(config.foo, 'foo-test');
assert.equal(config.bar, 'bar-test');
assert.equal(config.buz, 'buzz-*');
});
it('should not be possible to change a value', function() {
(function() {
assert.throws(function() {
config.foo = 'foo-changed';
}).should.throw();
config.foo.should.equal('foo-test');
}, Error);
assert.equal(config.foo, 'foo-test');
});
it('should not be possible to delete values', function() {
(function() {
assert.throws(function() {
delete config.foo;
}).should.throw();
config.foo.should.equal('foo-test');
}, Error);
assert.equal(config.foo, 'foo-test');
});
it('should not be possible to add new values', function() {
(function(){
assert.throws(function(){
config.whatever = 'whatever';
should.strictEqual(config.whatever, undefined);
}).should.throw();
assert.strictEqual(config.whatever, undefined);
}, Error);
});

@@ -79,3 +79,3 @@ });

it('should only iterate config values', function() {
Object.keys(config).should.have.lengthOf(3);
assert.equal(Object.keys(config).length, 3);
});

@@ -82,0 +82,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc