1
0
mirror of https://github.com/go-task/task.git synced 2025-01-06 03:53:54 +02:00

Make golint happy

This commit is contained in:
Andrey Nering 2017-02-28 09:50:40 -03:00
parent f2843589a9
commit a15cf26842

23
task.go
View File

@ -11,10 +11,14 @@ import (
) )
var ( var (
// TaskFilePath is the default Taskfile
TaskFilePath = "Taskfile.yml" TaskFilePath = "Taskfile.yml"
ShExists bool // ShExists is true if Bash was found
ShPath string ShExists bool
// ShPath constains the Bash path if found
ShPath string
// Tasks constains the tasks parsed from Taskfile
Tasks = make(map[string]*Task) Tasks = make(map[string]*Task)
) )
@ -27,6 +31,7 @@ func init() {
ShExists = true ShExists = true
} }
// Task represents a task
type Task struct { type Task struct {
Cmds []string Cmds []string
Deps []string Deps []string
@ -34,23 +39,24 @@ type Task struct {
Generates []string Generates []string
} }
type TaskNotFoundError struct { type taskNotFoundError struct {
taskName string taskName string
} }
func (err *TaskNotFoundError) Error() string { func (err *taskNotFoundError) Error() string {
return fmt.Sprintf(`Task "%s" not found`, err.taskName) return fmt.Sprintf(`Task "%s" not found`, err.taskName)
} }
type TaskRunError struct { type taskRunError struct {
taskName string taskName string
err error err error
} }
func (err *TaskRunError) Error() string { func (err *taskRunError) Error() string {
return fmt.Sprintf(`Failed to run task "%s": %v`, err.taskName, err.err) return fmt.Sprintf(`Failed to run task "%s": %v`, err.taskName, err.err)
} }
// Run runs Task
func Run() { func Run() {
log.SetFlags(0) log.SetFlags(0)
@ -78,10 +84,11 @@ func Run() {
} }
} }
// RunTask runs a task by its name
func RunTask(name string) error { func RunTask(name string) error {
t, ok := Tasks[name] t, ok := Tasks[name]
if !ok { if !ok {
return &TaskNotFoundError{name} return &taskNotFoundError{name}
} }
if isTaskUpToDate(t) { if isTaskUpToDate(t) {
@ -97,7 +104,7 @@ func RunTask(name string) error {
for _, c := range t.Cmds { for _, c := range t.Cmds {
if err := runCommand(c); err != nil { if err := runCommand(c); err != nil {
return &TaskRunError{name, err} return &taskRunError{name, err}
} }
} }
return nil return nil