* Updates the current variation settings * * @param newSettings * @param saveToFile * @returns {ThemeConfig}
(newSettings, saveToFile)
| 57 | * @returns {ThemeConfig} |
| 58 | */ |
| 59 | async updateConfig(newSettings, saveToFile) { |
| 60 | let rawConfig; |
| 61 | let variation; |
| 62 | // Remove all variation settings that match theme's settings |
| 63 | this.currentVariationSettings = omit( |
| 64 | newSettings, |
| 65 | (value, key) => this.globalSettings[key] === value, |
| 66 | this, |
| 67 | ); |
| 68 | if (saveToFile) { |
| 69 | // Resetting the global settings so the only data saved to the file are the changes |
| 70 | // from a specific variation's settings. |
| 71 | rawConfig = await this.getRawConfig(); |
| 72 | variation = this._getVariation(rawConfig, this.variationIndex); |
| 73 | variation.settings = this.currentVariationSettings; |
| 74 | fs.writeFileSync(this.configPath, JSON.stringify(rawConfig, null, 2), { |
| 75 | encoding: 'utf-8', |
| 76 | }); |
| 77 | } |
| 78 | return this; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Theme Path Setter |
no test coverage detected