MCPcopy
hub / github.com/spicetify/cli / InitSetting

Function InitSetting

src/cmd/cmd.go:123–202  ·  view source on GitHub ↗

InitSetting parses theme settings and gets color section.

()

Source from the content-addressed store, hash-verified

121
122// InitSetting parses theme settings and gets color section.
123func InitSetting() {
124 replaceColors = settingSection.Key("replace_colors").MustBool(false)
125 injectCSS = settingSection.Key("inject_css").MustBool(false)
126 injectJS = settingSection.Key("inject_theme_js").MustBool(false)
127 overwriteAssets = settingSection.Key("overwrite_assets").MustBool(false)
128
129 themeName := settingSection.Key("current_theme").String()
130
131 if len(themeName) == 0 {
132 injectCSS = false
133 injectJS = false
134 replaceColors = false
135 overwriteAssets = false
136 return
137 }
138
139 themeFolder = getThemeFolder(themeName)
140
141 colorPath := filepath.Join(themeFolder, "color.ini")
142 cssPath := filepath.Join(themeFolder, "user.css")
143 assetsPath := filepath.Join(themeFolder, "assets")
144 jsPath := filepath.Join(themeFolder, "theme.js")
145
146 if replaceColors {
147 _, err := os.Stat(colorPath)
148 replaceColors = err == nil
149 }
150
151 if injectCSS {
152 _, err := os.Stat(cssPath)
153 injectCSS = err == nil
154 }
155
156 if injectJS {
157 _, err := os.Stat(jsPath)
158 injectJS = err == nil
159 if err != nil {
160 utils.CheckExistAndDelete(filepath.Join(appDestPath, "xpui", "extensions/theme.js"))
161 }
162 }
163
164 if overwriteAssets {
165 _, err := os.Stat(assetsPath)
166 overwriteAssets = err == nil
167 }
168
169 var err error
170 colorCfg, err = ini.InsensitiveLoad(colorPath)
171 if err != nil {
172 utils.PrintError("Cannot open file " + colorPath)
173 replaceColors = false
174 }
175
176 if !replaceColors {
177 return
178 }
179
180 sections := colorCfg.Sections()

Callers 5

mainFunction · 0.92
ThemeAssetPathFunction · 0.85
ThemeAllAssetsPathFunction · 0.85
WatchFunction · 0.85
AutoFunction · 0.85

Calls 5

CheckExistAndDeleteFunction · 0.92
PrintErrorFunction · 0.92
PrintWarningFunction · 0.92
getThemeFolderFunction · 0.85
GetSectionMethod · 0.65

Tested by

no test coverage detected