@@ -17,34 +17,36 @@ package main
17
17
18
18
import (
19
19
"bytes"
20
- "context"
21
20
"flag"
22
21
"fmt"
23
- "github.com/zikes/multistatus"
24
22
"log"
25
23
"os"
26
24
"strings"
27
25
"sync"
28
26
)
29
27
28
+ var PrintFormat = "%-32s | %s"
29
+
30
30
func init () {
31
31
log .SetOutput (os .Stdout )
32
32
}
33
33
34
34
func run (stage string , projects []string , conf * Config , args * Arguments ) error {
35
- workerSet := multistatus .New ()
36
- errors := map [string ]error {}
35
+ wg := & sync.WaitGroup {}
37
36
mutex := & sync.Mutex {}
37
+
38
+ errors := map [string ]error {}
38
39
for _ , p := range projects {
39
- worker := workerSet .Add (fmt .Sprintf ("Project: %s" , p ))
40
- go func (w * multistatus.Worker , project string ) {
40
+ wg .Add (1 )
41
+ go func (project string ) {
42
+ defer wg .Done ()
41
43
cmd , err := GetCommand (stage , project , conf )
42
44
45
+ log .Println (PrintFormat , project , fmt .Sprintf ("Running stage '%s'" , stage ))
43
46
if err != nil {
44
47
mutex .Lock ()
45
48
errors [project ] = err
46
49
mutex .Unlock ()
47
- w .Fail ()
48
50
return
49
51
}
50
52
@@ -55,24 +57,21 @@ func run(stage string, projects []string, conf *Config, args *Arguments) error {
55
57
mutex .Lock ()
56
58
errors [project ] = err
57
59
mutex .Unlock ()
58
- w .Fail ()
59
60
log .Println (buff .String ())
60
61
return
61
62
}
62
-
63
- w .Done ()
64
- }(worker , p )
63
+ log .Println (PrintFormat , buff .String ())
64
+ }(p )
65
65
}
66
- // Print the WorkerSet's status until all Workers have completed
67
- workerSet . Print ( context . Background () )
68
- mutex . Lock ()
66
+
67
+ wg . Wait ( )
68
+
69
69
if len (errors ) != 0 {
70
70
for project , err := range errors {
71
71
log .Printf ("Error with project %s:\n %s" , project , err .Error ())
72
72
}
73
73
os .Exit (1 )
74
74
}
75
- mutex .Unlock ()
76
75
return nil
77
76
}
78
77
0 commit comments