brrd / node-config-watch

Load configuration from a JSON file and watch for changes
https://www.npmjs.com/package/config-watch
Other
0 stars 0 forks source link

config-watch not in functional state on npm #1

Open robbiemu opened 8 years ago

robbiemu commented 8 years ago

I like the simplicity and general pattern in the documentation, but it doesn't work. I can't follow the basic documentation:

const Config = require("config-watch");

let config = new Config("config.json", {
    defaults: {
        foo: "bar",
        colors: {
            tree: "green",
            sky: "blue"
        }
    }
});
let foe = config.get('foo').replace('oo', 'oe')
config.set('foo', foe));

produces TypeError: Cannot read property 'get' of undefined

I get the same behavior if I move the get/set calls to the callback

brrd commented 8 years ago

Thanks for reporting. Does config.json exist? What is logged when you try to catch constructor errors by using a callback:

let config = new Config("config.json", {
    defaults: {
        foo: "bar",
        colors: {
            tree: "green",
            sky: "blue"
        }
    }
}, (err) => console.log(err));