Skip to content

Commit 0da130e

Browse files
committed
refactor: simplify some controls
1 parent 6e880c9 commit 0da130e

File tree

3 files changed

+9
-24
lines changed

3 files changed

+9
-24
lines changed

execext/exec.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,5 @@ func RunCommand(opts *RunCommandOptions) error {
4646
Stdout: opts.Stdout,
4747
Stderr: opts.Stderr,
4848
}
49-
if err = r.Run(); err != nil {
50-
return err
51-
}
52-
return nil
49+
return r.Run()
5350
}

task.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,11 @@ func (e *Executor) runDeps(ctx context.Context, call Call) error {
152152
return err
153153
}
154154

155-
if err = e.RunTask(ctx, Call{Task: dep, Vars: d.Vars}); err != nil {
156-
return err
157-
}
158-
return nil
155+
return e.RunTask(ctx, Call{Task: dep, Vars: d.Vars})
159156
})
160157
}
161158

162-
if err := g.Wait(); err != nil {
163-
return err
164-
}
165-
return nil
159+
return g.Wait()
166160
}
167161

168162
func (e *Executor) isTaskUpToDate(ctx context.Context, call Call) (bool, error) {
@@ -278,20 +272,17 @@ func (e *Executor) runCommand(ctx context.Context, call Call, i int) error {
278272
}
279273

280274
e.println(c)
281-
if t.Set == "" {
282-
opts.Stdout = e.Stdout
283-
if err = execext.RunCommand(opts); err != nil {
284-
return err
285-
}
286-
} else {
275+
if t.Set != "" {
287276
var stdout bytes.Buffer
288277
opts.Stdout = &stdout
289278
if err = execext.RunCommand(opts); err != nil {
290279
return err
291280
}
292-
os.Setenv(t.Set, strings.TrimSpace(stdout.String()))
281+
return os.Setenv(t.Set, strings.TrimSpace(stdout.String()))
293282
}
294-
return nil
283+
284+
opts.Stdout = e.Stdout
285+
return execext.RunCommand(opts)
295286
}
296287

297288
func (e *Executor) getTaskDir(call Call) (string, error) {

taskfile.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ func (e *Executor) ReadTaskfile() error {
3131
if err := mergo.MapWithOverwrite(&e.Tasks, osTasks); err != nil {
3232
return err
3333
}
34-
if err := e.readTaskvarsFile(); err != nil {
35-
return err
36-
}
37-
return nil
34+
return e.readTaskvarsFile()
3835
}
3936

4037
func (e *Executor) readTaskfileData(path string) (tasks map[string]*Task, err error) {

0 commit comments

Comments
 (0)