1
0
mirror of https://github.com/go-task/task.git synced 2025-11-06 09:09:13 +02:00
Files
task/internal/taskfile/task.go

47 lines
877 B
Go
Raw Normal View History

package taskfile
import "os"
import "sync"
2019-02-24 09:24:57 +01:00
// Tasks represents a group of tasks
type Tasks map[string]*Task
// Task represents a task
type Task struct {
2018-08-05 12:53:42 -03:00
Task string
Cmds []*Cmd
Deps []*Dep
Desc string
2019-02-24 15:37:02 +01:00
Summary string
2018-08-05 12:53:42 -03:00
Sources []string
Generates []string
Status []string
Dir string
mkdirMutex sync.Mutex
2018-08-05 12:53:42 -03:00
Vars Vars
Env Vars
Silent bool
Method string
Prefix string
IgnoreError bool `yaml:"ignore_error"`
}
// Mkdir creates the directory Task.Dir.
// Safe to be called concurrently.
func (t *Task) Mkdir() error {
if t.Dir == "" {
// No "dir:" attribute, so we do nothing.
return nil
}
t.mkdirMutex.Lock()
defer t.mkdirMutex.Unlock()
if _, err := os.Stat(t.Dir); os.IsNotExist(err) {
if err := os.MkdirAll(t.Dir, 0755); err != nil {
return err
}
}
return nil
}