Giter VIP home page Giter VIP logo

Comments (4)

benurb avatar benurb commented on May 27, 2024 1

Hey @meaku

I created a PR, that follows your suggestion. Instead of Object.assign I used the deep-assign module, because of two reasons:

  1. Object.assign is not available in node 0.12
  2. Object.assign is only shallow, but imho it should be possible to also overwrite nested properties without specifying the whole child object chain in the overwrite file

Let me know what you think 😄

Ben

from dynamic-config.

meaku avatar meaku commented on May 27, 2024

Thanks for your proposal @benurb!

I like the idea of having a local config. It could be a plugin and used if needed.

Another option would be to add the logic to your config.js

//config/index.js

const path = require("path");
const dynamicConfig = require("dynamic-config");

let localConfigPath = path.join(__dirname, "config.local.js");

let config = dynamicConfig(__dirname, "config.js");

if(fs.existsSync(localConfigPath) {
    config = Object.assign(config, fs.readFileSync(localConfigPath)); 
}

module.exports = config;

But i'd be happy with a PR adding this functionality as a plugin 👍

We already have an extend plugin which reads from env and argv. Maybe it's extend/file or extend/localfile?

from dynamic-config.

meaku avatar meaku commented on May 27, 2024

Looks good! I added some comments about some copy & paste things. If you agree this PR can land :)

from dynamic-config.

benurb avatar benurb commented on May 27, 2024

Already landed in 207cd1e. Thank you guys 👍

from dynamic-config.

Related Issues (6)

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.