Skip to content

Commit bb173f1

Browse files
avdvachew22
authored andcommitted
Run output during initialization
1 parent dd40d76 commit bb173f1

File tree

6 files changed

+16
-6
lines changed

6 files changed

+16
-6
lines changed

internal/ibazel/ibazel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func New(version string) (*IBazel, error) {
116116

117117
info, stderrBuffer, _ := i.getInfo()
118118
for _, l := range i.lifecycleListeners {
119-
l.Initialize(&info)
119+
l.Initialize(&info, stderrBuffer)
120120
}
121121

122122
go func() {

internal/ibazel/lifecycle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
type Lifecycle interface {
1212
// Initialize is called once it is known that this lifecycle client is going
1313
// to be used.
14-
Initialize(info *map[string]string)
14+
Initialize(info *map[string]string, stderrBuffer *bytes.Buffer)
1515

1616
// TargetDecider takes a protobuf rule and performs setup if it matches the
1717
// listener's expectations.

internal/ibazel/lifecycle_hooks/lifecycle_hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func New() *LifecycleHooks {
4343
}
4444
}
4545

46-
func (l *LifecycleHooks) Initialize(info *map[string]string) {}
46+
func (l *LifecycleHooks) Initialize(info *map[string]string, stderrBuffer *bytes.Buffer) {}
4747

4848
func (l *LifecycleHooks) TargetDecider(rule *blaze_query.Rule) {}
4949

internal/ibazel/live_reload/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (l *LiveReloadServer) AddEventsListener(listener Events) {
4747
l.eventListeners = append(l.eventListeners, listener)
4848
}
4949

50-
func (l *LiveReloadServer) Initialize(info *map[string]string) {}
50+
func (l *LiveReloadServer) Initialize(info *map[string]string, stderrBuffer *bytes.Buffer) {}
5151

5252
func (l *LiveReloadServer) Cleanup() {
5353
if l.lrserver != nil {

internal/ibazel/output_runner/output_runner.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ func New() *OutputRunner {
6464
return i
6565
}
6666

67-
func (i *OutputRunner) Initialize(info *map[string]string) {}
67+
func (i *OutputRunner) Initialize(info *map[string]string, output *bytes.Buffer) {
68+
if *runOutput == false || output == nil {
69+
return
70+
}
71+
72+
i.executeOutput(output)
73+
}
6874

6975
func (i *OutputRunner) TargetDecider(rule *blaze_query.Rule) {}
7076

@@ -77,6 +83,10 @@ func (i *OutputRunner) AfterCommand(targets []string, command string, success bo
7783
return
7884
}
7985

86+
i.executeOutput(output)
87+
}
88+
89+
func (i *OutputRunner) executeOutput(output *bytes.Buffer) {
8090
jsonCommandPath := ".bazel_fix_commands.json"
8191
defaultRegex := Optcmd{
8292
Regex: "^buildozer '(.*)'\\s+(.*)$",

internal/ibazel/profiler/profiler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func New(version string) *Profiler {
100100
return p
101101
}
102102

103-
func (i *Profiler) Initialize(info *map[string]string) {
103+
func (i *Profiler) Initialize(info *map[string]string, _stderrBuffer *bytes.Buffer) {
104104
if *profileDev == "" {
105105
return
106106
}

0 commit comments

Comments
 (0)