mirror of
https://github.com/go-task/task.git
synced 2026-06-11 09:51:50 +00:00
refactor: merge Setup into NewExecutor
This commit is contained in:
@@ -152,17 +152,12 @@ func run() error {
|
||||
return err
|
||||
}
|
||||
|
||||
tf, err := graph.Merge()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
executor := task.NewExecutor(tf,
|
||||
executor, err := task.NewExecutor(graph,
|
||||
flags.WithFlags(),
|
||||
task.WithDir(node.Dir()),
|
||||
task.WithTempDir(tempDir),
|
||||
)
|
||||
if err := executor.Setup(); err != nil {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
11
executor.go
11
executor.go
@@ -71,7 +71,11 @@ type (
|
||||
|
||||
// NewExecutor creates a new [Executor] and applies the given functional options
|
||||
// to it.
|
||||
func NewExecutor(tf *ast.Taskfile, opts ...ExecutorOption) *Executor {
|
||||
func NewExecutor(graph *ast.TaskfileGraph, opts ...ExecutorOption) (*Executor, error) {
|
||||
tf, err := graph.Merge()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
e := &Executor{
|
||||
Taskfile: tf,
|
||||
Stdin: os.Stdin,
|
||||
@@ -91,7 +95,10 @@ func NewExecutor(tf *ast.Taskfile, opts ...ExecutorOption) *Executor {
|
||||
executionHashesMutex: sync.Mutex{},
|
||||
}
|
||||
e.Options(opts...)
|
||||
return e
|
||||
if err := e.setup(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return e, nil
|
||||
}
|
||||
|
||||
// Options loops through the given [ExecutorOption] functions and applies them
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"github.com/go-task/task/v3/taskfile/ast"
|
||||
)
|
||||
|
||||
func (e *Executor) Setup() error {
|
||||
func (e *Executor) setup() error {
|
||||
e.setupLogger()
|
||||
e.setupFuzzyModel()
|
||||
e.setupStdFiles()
|
||||
Reference in New Issue
Block a user