(browsers []browser.Browser, categories []types.Category, outputDir, outputFormat string, compress bool)
| 12 | ) |
| 13 | |
| 14 | func extractAndWrite(browsers []browser.Browser, categories []types.Category, outputDir, outputFormat string, compress bool) error { |
| 15 | w, err := output.NewWriter(outputDir, outputFormat) |
| 16 | if err != nil { |
| 17 | return err |
| 18 | } |
| 19 | for _, b := range browsers { |
| 20 | log.Infof("Extracting %s...", b.BrowserName()) |
| 21 | results, extractErr := b.Extract(categories) |
| 22 | if extractErr != nil { |
| 23 | log.Errorf("extract %s: %v", b.BrowserName(), extractErr) |
| 24 | } |
| 25 | for _, r := range results { |
| 26 | w.Add(b.BrowserName(), r.Name, r.Data) |
| 27 | } |
| 28 | } |
| 29 | if err := w.Write(); err != nil { |
| 30 | return err |
| 31 | } |
| 32 | if compress { |
| 33 | if err := fileutil.CompressDir(outputDir); err != nil { |
| 34 | return fmt.Errorf("compress: %w", err) |
| 35 | } |
| 36 | log.Infof("Compressed: %s/%s.zip", outputDir, filepath.Base(outputDir)) |
| 37 | } |
| 38 | return nil |
| 39 | } |
no test coverage detected