Skip to content

Commit

Permalink
Add force update to set
Browse files Browse the repository at this point in the history
  • Loading branch information
taylortom authored Nov 13, 2024
1 parent 7fdcfde commit fd4925d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/ConfigModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class ConfigModule extends AbstractModule {
throw e
}
// apply validated config settings
Object.entries(data).forEach(([key, val]) => this.set(`${pkg.name}.${key}`, val))
Object.entries(data).forEach(([key, val]) => this.set(`${pkg.name}.${key}`, val, { force: true }))
}

/**
Expand All @@ -208,9 +208,11 @@ class ConfigModule extends AbstractModule {
* Stores a value for the passed attribute
* @param {String} attr Attribute key name
* @param {*} val Value to set
* @param {objeect} options Custom options
* @param {objeect} options.force Whether to force an update
*/
set (attr, val) {
if (this.has(attr) && !this.mutableAttributes.includes(attr)) {
set (attr, val, options = {}) {
if (this.has(attr) && !this.mutableAttributes.includes(attr) && options.force !== true) {
return
}
this._config[attr] = val
Expand Down

0 comments on commit fd4925d

Please sign in to comment.