mirror of
https://github.com/go-task/task.git
synced 2025-11-29 22:48:03 +02:00
Only run task once for #53
This commit is contained in:
committed by
Andrey Nering
parent
a7b59e5b12
commit
97c85e39c3
28
hash.go
Normal file
28
hash.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-task/task/v3/internal/hash"
|
||||
"github.com/go-task/task/v3/taskfile"
|
||||
)
|
||||
|
||||
func (e *Executor) GetHash(t *taskfile.Task) (string, error) {
|
||||
r := t.Run
|
||||
if r == "" {
|
||||
r = e.Taskfile.Run
|
||||
}
|
||||
|
||||
var h hash.HashFunc
|
||||
switch r {
|
||||
case "always":
|
||||
h = hash.Empty
|
||||
case "once":
|
||||
h = hash.Name
|
||||
case "when_changed":
|
||||
h = hash.Hash
|
||||
default:
|
||||
return "", fmt.Errorf(`task: invalid run "%s"`, r)
|
||||
}
|
||||
return h(t)
|
||||
}
|
||||
Reference in New Issue
Block a user