func hash(t string) { c := builder.New() if c.ProjectPath == "" { fmt.Fprintf(os.Stderr, "You need to be in a git project.\n\n") printUsage() } fmt.Printf("%x\n", c.Add(t).HashNode()) }
func execute(t string) { c := builder.New() if c.ProjectPath == "" { fmt.Fprintf(os.Stderr, "You need to be in a git project.\n\n") printUsage() } c.Root = c.Add(t) c.Root.IsRoot = true if c.Root == nil { log.Fatal("We couldn't find the root") } cpus := int(float32(runtime.NumCPU()) * 1.25) done := make(chan bool) // If the app hangs, there is a log. sigs := make(chan os.Signal, 1) signal.Notify(sigs, os.Interrupt) go func() { <-sigs f, _ := os.Create("/tmp/build-crash-log.json") fmt.Fprintf(f, prettyprint.AsJSON(c.Root)) os.Exit(1) }() go term.Listen(c.Updates, cpus, *verbose) go term.Run(done) go c.Execute(time.Second, cpus) for { select { case done := <-c.Done: if *verbose { doneMessage(done.Url.String()) } if done.IsRoot { goto FIN } case err := <-c.Error: <-done log.Fatal(err) os.Exit(1) case <-c.Timeout: log.Println("your build has timed out") } } FIN: term.Exit() <-done os.Exit(0) }
func query(t string) { c := builder.New() if c.ProjectPath == "" { fmt.Fprintf(os.Stderr, "You need to be in a git project.\n\n") printUsage() } fmt.Println(prettyprint.AsJSON(c.Add(t).Target)) }
func graph(w http.ResponseWriter, r *http.Request) { c := builder.New() if c.ProjectPath == "" { fmt.Fprintf(os.Stderr, "You need to be in a git project.\n\n") printUsage() } c.Add(targetName) w.Write([]byte(prettyprint.AsJSON(c.Nodes[targetName]))) }