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

Function WatchExtensions

src/cmd/watch.go:105–147  ·  view source on GitHub ↗

WatchExtensions .

(extName []string, liveUpdate bool)

Source from the content-addressed store, hash-verified

103
104// WatchExtensions .
105func WatchExtensions(extName []string, liveUpdate bool) {
106 if !isValidForWatching() {
107 os.Exit(1)
108 }
109
110 if liveUpdate {
111 startDebugger()
112 }
113
114 var extNameList []string
115 if len(extName) > 0 {
116 extNameList = extName
117 } else {
118 extNameList = featureSection.Key("extensions").Strings("|")
119 }
120
121 var extPathList []string
122
123 for _, v := range extNameList {
124 extPath, err := utils.GetExtensionPath(v)
125 if err != nil {
126 utils.PrintError(`Extension "` + v + `" not found.`)
127 continue
128 }
129 extPathList = append(extPathList, extPath)
130 }
131
132 if len(extPathList) == 0 {
133 utils.PrintError("No extension to watch")
134 os.Exit(1)
135 }
136
137 utils.Watch(extPathList, func(filePath string, err error) {
138 if err != nil {
139 utils.PrintError(err.Error())
140 os.Exit(1)
141 }
142
143 pushExtensions("", filePath)
144
145 utils.PrintSuccess(utils.PrependTime(`Extension "` + filePath + `" is updated`))
146 }, autoReloadFunc)
147}
148
149// WatchCustomApp .
150func WatchCustomApp(appName []string, liveUpdate bool) {

Callers 1

mainFunction · 0.92

Calls 8

GetExtensionPathFunction · 0.92
PrintErrorFunction · 0.92
WatchFunction · 0.92
PrintSuccessFunction · 0.92
PrependTimeFunction · 0.92
isValidForWatchingFunction · 0.85
startDebuggerFunction · 0.85
pushExtensionsFunction · 0.85

Tested by

no test coverage detected