Skip to content

Commit 6b2a6d1

Browse files
authored
fix: stops process on service/website build errors (#861)
1 parent ef4f63e commit 6b2a6d1

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

cmd/debug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ var specCmd = &cobra.Command{
147147
buildModel, err := prog.Run()
148148
tui.CheckErr(err)
149149
if buildModel.(build.Model).Err != nil {
150-
tui.CheckErr(fmt.Errorf("error building services"))
150+
tui.CheckErr(fmt.Errorf("error building migration images"))
151151
}
152152
}
153153
}

cmd/run.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,24 @@ var runCmd = &cobra.Command{
138138

139139
// non-interactive environment
140140
for update := range allBuildUpdates {
141+
if update.Status == project.ServiceBuildStatus_Error {
142+
localCloud.Stop()
143+
tui.CheckErr(fmt.Errorf("error building services"))
144+
}
145+
141146
for _, line := range strings.Split(strings.TrimSuffix(update.Message, "\n"), "\n") {
142147
fmt.Printf("%s [%s]: %s\n", update.ServiceName, update.Status, line)
143148
}
144149
}
145150
} else {
146151
prog := teax.NewProgram(build.NewModel(allBuildUpdates, "Building Services"))
147152
// blocks but quits once the above updates channel is closed by the build process
148-
_, err = prog.Run()
153+
buildModel, err := prog.Run()
149154
tui.CheckErr(err)
155+
if buildModel.(build.Model).Err != nil {
156+
localCloud.Stop()
157+
tui.CheckErr(fmt.Errorf("error building services"))
158+
}
150159
}
151160

152161
websiteBuildUpdates, err := proj.BuildWebsites(loadEnv)
@@ -156,15 +165,25 @@ var runCmd = &cobra.Command{
156165
if isNonInteractive() {
157166
fmt.Println("building project websites")
158167
for update := range websiteBuildUpdates {
168+
if update.Status == project.ServiceBuildStatus_Error {
169+
localCloud.Stop()
170+
tui.CheckErr(fmt.Errorf("error building websites"))
171+
}
172+
159173
for _, line := range strings.Split(strings.TrimSuffix(update.Message, "\n"), "\n") {
160174
fmt.Printf("%s [%s]: %s\n", update.ServiceName, update.Status, line)
161175
}
162176
}
163177
} else {
164178
prog := teax.NewProgram(build.NewModel(websiteBuildUpdates, "Building Websites"))
165179
// blocks but quits once the above updates channel is closed by the build process
166-
_, err = prog.Run()
180+
buildModel, err := prog.Run()
167181
tui.CheckErr(err)
182+
183+
if buildModel.(build.Model).Err != nil {
184+
localCloud.Stop()
185+
tui.CheckErr(fmt.Errorf("error building websites"))
186+
}
168187
}
169188
}
170189

cmd/stack.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ var stackUpdateCmd = &cobra.Command{
198198

199199
// non-interactive environment
200200
for update := range allBuildUpdates {
201+
if update.Status == project.ServiceBuildStatus_Error {
202+
tui.CheckErr(fmt.Errorf("error building services"))
203+
}
204+
201205
for _, line := range strings.Split(strings.TrimSuffix(update.Message, "\n"), "\n") {
202206
fmt.Printf("%s [%s]: %s\n", update.ServiceName, update.Status, line)
203207
}
@@ -272,7 +276,7 @@ var stackUpdateCmd = &cobra.Command{
272276
buildModel, err := prog.Run()
273277
tui.CheckErr(err)
274278
if buildModel.(build.Model).Err != nil {
275-
tui.CheckErr(fmt.Errorf("error building services"))
279+
tui.CheckErr(fmt.Errorf("error building migration images"))
276280
}
277281
}
278282
}
@@ -284,15 +288,23 @@ var stackUpdateCmd = &cobra.Command{
284288
if isNonInteractive() {
285289
fmt.Println("building project websites")
286290
for update := range websiteBuildUpdates {
291+
if update.Status == project.ServiceBuildStatus_Error {
292+
tui.CheckErr(fmt.Errorf("error building websites"))
293+
}
294+
287295
for _, line := range strings.Split(strings.TrimSuffix(update.Message, "\n"), "\n") {
288296
fmt.Printf("%s [%s]: %s\n", update.ServiceName, update.Status, line)
289297
}
290298
}
291299
} else {
292300
prog := teax.NewProgram(build.NewModel(websiteBuildUpdates, "Building Websites"))
293301
// blocks but quits once the above updates channel is closed by the build process
294-
_, err = prog.Run()
302+
buildModel, err := prog.Run()
295303
tui.CheckErr(err)
304+
305+
if buildModel.(build.Model).Err != nil {
306+
tui.CheckErr(fmt.Errorf("error building websites"))
307+
}
296308
}
297309
}
298310

0 commit comments

Comments
 (0)