func enqueueEvents(client themekit.ThemeClient, filenames []string, events chan themekit.AssetEvent) { root, _ := os.Getwd() if len(filenames) == 0 { go fullReplace(client.AssetListSync(), client.LocalAssets(root), events) return } go func() { for _, filename := range filenames { asset, err := themekit.LoadAsset(root, filename) if err == nil { events <- themekit.NewUploadEvent(asset) } } close(events) }() }
func spawnWorker(workerName string, queue chan themekit.AssetEvent, client themekit.ThemeClient, eventLog chan themekit.ThemeEvent) { logEvent(workerSpawnEvent(workerName), eventLog) for { asset := <-queue if asset.Asset().IsValid() { workerEvent := basicEvent{ Title: "FS Event", EventType: asset.Type().String(), Target: asset.Asset().Key, etype: "fsevent", Formatter: func(b basicEvent) string { return fmt.Sprintf( "Received %s event on %s", themekit.GreenText(b.EventType), themekit.BlueText(b.Target), ) }, } logEvent(workerEvent, eventLog) logEvent(client.Perform(asset), eventLog) } } }