MCPcopy Create free account
hub / github.com/bigcommerce/stencil-cli / updateConfig

Method updateConfig

lib/theme-config.js:59–79  ·  view source on GitHub ↗

* Updates the current variation settings * * @param newSettings * @param saveToFile * @returns {ThemeConfig}

(newSettings, saveToFile)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 2

getRawConfigMethod · 0.95
_getVariationMethod · 0.95

Tested by

no test coverage detected