Skip to content

Commit 947b3de

Browse files
committed
Merge branch 'watch'
2 parents 36614dc + 18e668f commit 947b3de

File tree

222 files changed

+126373
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+126373
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@ build Build the go binary.
322322
test Run all the go tests.
323323
```
324324

325+
## Watch tasks (experimental)
326+
327+
If you give a `--watch` or `-w` argument, task will watch for files changes
328+
and run the task again. This requires the `sources` attribute to be given,
329+
so task know which files to watch.
330+
325331
## Alternatives
326332

327333
Similar software:

cmd/task/task.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ hello:
2626
pflag.PrintDefaults()
2727
}
2828
pflag.BoolVarP(&task.Force, "force", "f", false, "forces execution even when the task is up-to-date")
29+
pflag.BoolVarP(&task.Watch, "watch", "w", false, "enables watch of the given task")
2930
pflag.Parse()
3031
task.Run()
3132
}

errors.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,11 @@ type cyclicDepError struct {
3636
func (err *cyclicDepError) Error() string {
3737
return fmt.Sprintf(`task: Cyclic dependency of task "%s" detected`, err.taskName)
3838
}
39+
40+
type cantWatchNoSourcesError struct {
41+
taskName string
42+
}
43+
44+
func (err *cantWatchNoSourcesError) Error() string {
45+
return fmt.Sprintf(`task: Can't watch task "%s" because it has no specified sources`, err.taskName)
46+
}

task.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ var (
1818

1919
// Force (--force or -f flag) forces a task to run even when it's up-to-date
2020
Force bool
21+
// Watch (--watch or -w flag) enables watch of a task
22+
Watch bool
2123

2224
// Tasks constains the tasks parsed from Taskfile
2325
Tasks = make(map[string]*Task)
@@ -66,6 +68,13 @@ func Run() {
6668
}
6769
}
6870

71+
if Watch {
72+
if err := WatchTasks(args); err != nil {
73+
log.Fatal(err)
74+
}
75+
return
76+
}
77+
6978
for _, a := range args {
7079
if err = RunTask(a); err != nil {
7180
log.Fatal(err)

vendor/github.com/fsnotify/fsnotify/AUTHORS

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)