Skip to content

default_env is not properly encapsulated. #11

@cfurst

Description

@cfurst

Let's say you have lib a that usues envious as well as your own script that uses envious:
lib A has the following config file:

var envious = require('envious');
envious.qa = {
"places" : { "oneplace":"/one/path",
                 "anotherplace": "/another/path"}
}
envious.dev={
  "places":{"oneplace":"/one/path"}
}
envious.default_env="dev"
var config = envious.apply()
module.exports = config

now in your config you have the following:

var envious = require('envious');
envious.qa = {
"places" : { "one":"1",
                 "two": "10"}
}
envious.dev={
  "places":{"one" : "1"}
}
// no default declared here!
var config = envious.apply();
modules.export = config;

The configuration in your script INHERITS the default_env decalration in the library and will now inherit, unintentionally, all the undeclared keys of envious.dev.places, no matter what you set NODE_ENV to. Which of course will cause unexpected behavior in your code.

You have to set default_env to a "falsy" value to cancel it out. However in envious.js there is no warning, nor error thrown if there is a declaration of that default env.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions