Permalink
Browse files

Changed to not reload configurations after initially loaded

  • Loading branch information...
1 parent 263dc80 commit e5b3a91d908a54be79d1cd70d884711fa32d59d6 @doug-martin doug-martin committed Mar 20, 2013
Showing with 26 additions and 14 deletions.
  1. 0 .npmignore
  2. +25 −13 lib/index.js
  3. +1 −1 package.json
View
No changes.
View
@@ -122,24 +122,36 @@ var Config = PatternEventEmitter.extend({
load: function (cb) {
- var ret = _.when(this.locations.concat(this.files).map(function (f) {
- var loader = new Loader(f, {monitor: this.monitor});
- return loader.load().then(function () {
- return loader;
- });
- }, this)).then(function (loaders) {
- return this.__mergeLoaders(loaders).config;
- }.bind(this));
+ var ret;
+ if (!this.__loaded) {
+ ret = _.when(this.locations.concat(this.files).map(function (f) {
+ var loader = new Loader(f, {monitor: this.monitor});
+ return loader.load().then(function () {
+ return loader;
+ });
+ }, this)).then(function (loaders) {
+ this.__loaded = true;
+ return this.__mergeLoaders(loaders).config;
+ }.bind(this));
+ } else {
+ ret = _.resolve(this.config);
+ }
ret.classic(cb);
return ret;
},
loadSync: function () {
- return this.__mergeLoaders((this.loaders = this.locations.concat(this.files).map(function (f) {
- var loader = new Loader(f, {monitor: this.monitor});
- loader.loadSync();
- return loader;
- }, this))).config;
+ if (!this.__loaded) {
+ var ret = this.__mergeLoaders((this.loaders = this.locations.concat(this.files).map(function (f) {
+ var loader = new Loader(f, {monitor: this.monitor});
+ loader.loadSync();
+ return loader;
+ }, this))).config;
+ this.__loaded = true;
+ return ret;
+ } else {
+ return this.config;
+ }
}
}
});
View
@@ -1,7 +1,7 @@
{
"name": "gofigure",
"description": "Configuration helper for node",
- "version": "0.1.0",
+ "version": "0.1.1",
"scripts": {
"test": "grunt it"
},

0 comments on commit e5b3a91

Please sign in to comment.