Giter Club home page Giter Club logo

Comments (5)

dlong500 avatar dlong500 commented on August 19, 2024 1

Sorry to be a necromancer with this issue, but the whole order of how nconf loads values seems counterintuitive. It's probably way too late to have anything change at this point, but I would expect things to work more like CSS definitions or the spread operator with javascript objects (where the last value specified for a given key takes precedence). Something similar (in terms of order) to below:

const config = {
  ...defaults,
  ...fileA,
  ...fileB,
  ...args,
  ...overrides,
}

nconf basically works the exact opposite of the above, with the first value for a specified key overriding any later entry. It's certainly not impossible or even hard to use this way, but it does seem like most other resolvers take a later value over an earlier one.

from nconf.

leostera avatar leostera commented on August 19, 2024

👍

from nconf.

Guuz avatar Guuz commented on August 19, 2024

This!

I ran into this today. And still see not workaround for this. For my tests i would like to declare some defaults to use, so my tests are always running with fixed values.

from nconf.

gdw2 avatar gdw2 commented on August 19, 2024

The 'workaround' is to just put defaults at the very end -- just like in the example in the readme. That way, overrides are unchangable, then env and args are applied, then the config files, and finally defaults. These scheme has worked great for me! Btw, looking at the code you can see that defaults and overrides are the same thing.

from nconf.

OmgImAlexis avatar OmgImAlexis commented on August 19, 2024

👍

from nconf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.