Skip to content

Commit

Permalink
feat(config): use a deep merge for merging the run-time and the envir…
Browse files Browse the repository at this point in the history
…onment config (#287)
  • Loading branch information
cbourget authored and mbarbeau committed Apr 10, 2019
1 parent 6f0b78c commit 459a9e9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/core/src/lib/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ConfigOptions } from './config.interface';
providedIn: 'root'
})
export class ConfigService {

private config: object = {};

constructor(private injector: Injector) {}
Expand All @@ -26,11 +27,9 @@ export class ConfigService {
* This method loads "[path]" to get all config's variables
*/
public load(options: ConfigOptions) {
if (options.default) {
this.config = options.default;
}

const baseConfig = options.default || {};
if (!options.path) {
this.config = baseConfig;
return true;
}

Expand All @@ -51,7 +50,7 @@ export class ConfigService {
)
)
.subscribe(configResponse => {
Object.assign(this.config, configResponse);
this.config = ObjectUtils.mergeDeep(baseConfig, configResponse);
resolve(true);
});
});
Expand Down

0 comments on commit 459a9e9

Please sign in to comment.