Skip to content

Commit

Permalink
feat: add ability to set watch: true in Taskfile
Browse files Browse the repository at this point in the history
  • Loading branch information
andreynering committed Oct 6, 2023
1 parent f0d2551 commit 037d13f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions task.go
Expand Up @@ -123,6 +123,17 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error {
return nil
}

if len(calls) == 1 {
t, err := e.GetTask(calls[0])
if err != nil {
return err
}

if t.Watch {
return e.watchTasks(calls...)
}
}

if e.Watch {
return e.watchTasks(calls...)
}
Expand Down
3 changes: 3 additions & 0 deletions taskfile/task.go
Expand Up @@ -41,6 +41,7 @@ type Task struct {
IncludedTaskfile *IncludedTaskfile
Platforms []*Platform
Location *Location
Watch bool
}

func (t *Task) Name() string {
Expand Down Expand Up @@ -101,6 +102,7 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error {
Run string
Platforms []*Platform
Requires *Requires
Watch bool
}
if err := node.Decode(&task); err != nil {
return err
Expand Down Expand Up @@ -138,6 +140,7 @@ func (t *Task) UnmarshalYAML(node *yaml.Node) error {
t.Run = task.Run
t.Platforms = task.Platforms
t.Requires = task.Requires
t.Watch = task.Watch
return nil
}

Expand Down
1 change: 1 addition & 0 deletions variables.go
Expand Up @@ -70,6 +70,7 @@ func (e *Executor) compiledTask(call taskfile.Call, evaluateShVars bool) (*taskf
Platforms: origTask.Platforms,
Location: origTask.Location,
Requires: origTask.Requires,
Watch: origTask.Watch,
}
new.Dir, err = execext.Expand(new.Dir)
if err != nil {
Expand Down

0 comments on commit 037d13f

Please sign in to comment.