Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Changed to not reload configurations after initially loaded #9

Merged
merged 1 commit into from

1 participant

@doug-martin
Owner

No description provided.

@doug-martin doug-martin merged commit d291671 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 26 additions and 14 deletions.
  1. 0  .npmignore
  2. +25 −13 lib/index.js
  3. +1 −1  package.json
View
0  .npmignore
No changes.
View
38 lib/index.js
@@ -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
2  package.json
@@ -1,7 +1,7 @@
{
"name": "gofigure",
"description": "Configuration helper for node",
- "version": "0.1.0",
+ "version": "0.1.1",
"scripts": {
"test": "grunt it"
},
Something went wrong with that request. Please try again.