func uploadFiles(scriptsPath, user, password, host string) error { args := []string{user, password, host} if err := utils.ExecCopyOutput(filepath.Join(scriptsPath, "upload.sh"), args); err != nil { return fmt.Errorf("upload script failed: %s", err) } return nil }
func test(c *config.Config, q *registry.Queue) error { args := []string{"start"} if *config.NoColors { args = append(args, "--no-colors") } args = append(args, "config/karma.conf.js") if err := utils.ExecCopyOutput("karma", args); err != nil { return fmt.Errorf("exec failed: %s", err) } return nil }
func testGreedy(c *config.Config, q *registry.Queue) error { args := []string{"start"} if *config.NoColors { args = append(args, "--no-colors") } parts := strings.Split(q.CurTask, ":") args = append(args, fmt.Sprintf("config/karma-%s.conf.js", parts[1])) if err := utils.ExecCopyOutput("karma", args); err != nil { return fmt.Errorf("exec failed: %s", err) } return nil }
func testSubl(c *config.Config, q *registry.Queue) error { args := []string{ "start", "--reporters", "dots", "--no-colors", "config/karma.conf.js", "--single-run", } if err := utils.ExecCopyOutput("karma", args); err != nil { return fmt.Errorf("exec failed: %s", err) } return nil }
func update(c *config.Config, q *registry.Queue) error { // Fetch last commits, both localy & remotely latestSha, err := fetchLatestCommit() if err != nil { return err } currentSha, err := fetchCurrentCommit() if err != nil { return err } // Couldn't retrieve current/latest commit, ignore update if latestSha == "" || currentSha == "" { if *config.Verbose { log.Printf("local or remote version was not retrieved correctly\n") } return nil } if err := writeCheckUpdate(); err != nil { return err } // No update, return directly if latestSha == currentSha { if *config.Verbose { log.Printf("same version detected\n") } return nil } // Perform the update args := []string{"get", "-u", "github.com/ernestokarim/cb"} output, err := utils.Exec("go", args) if err != nil { return err } if len(output) > 0 { fmt.Println(output) } log.Printf("%sUpdated correctly to commit: %s%s", colors.Green, latestSha[:10], colors.Reset) // Rerun itself with the correct args if err := utils.ExecCopyOutput(os.Args[0], os.Args[1:]); err != nil { return fmt.Errorf("error re-executing itself with the same arguments: %s", err) } os.Exit(1) panic("should not be reached") }
func deploy(c *config.Config, q *registry.Queue) error { parts := strings.Split(q.CurTask, ":") base := utils.PackagePath(filepath.Join(selfPkg, parts[1]+".sh")) args := []string{ filepath.Base(c.GetRequired("paths.base")), } if err := utils.ExecCopyOutput(base, args); err != nil { return fmt.Errorf("deploy failed: %s", err) } if err := organizeResult(c); err != nil { return fmt.Errorf("cannot organize result: %s", err) } return nil }
func postInit() error { // Test if the post-init file exists if _, err := os.Stat("post-init.sh"); err != nil { if os.IsNotExist(err) { if *config.Verbose { log.Println("post-init.sh file doesn't exist") } return nil } return fmt.Errorf("err failed") } if *config.Verbose { log.Println("running post-init.sh file") } // Run it if err := utils.ExecCopyOutput("bash", []string{"./post-init.sh"}); err != nil { return fmt.Errorf("post init exec failed: %s", err) } return nil }