1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

refactor: Create executor struct to get rid of global variables

Maybe eventually help on #17
This commit is contained in:
Andrey Nering
2017-06-04 16:02:04 -03:00
parent c40148a52e
commit f98bf6c4b1
9 changed files with 137 additions and 109 deletions

10
init.go
View File

@@ -13,17 +13,17 @@ default:
- echo "Hello, World!"
`
func initTaskfile() {
// InitTaskfile Taskfile creates a new Taskfile
func InitTaskfile() error {
for _, f := range []string{"Taskfile.yml", "Taskfile.toml", "Taskfile.json"} {
if _, err := os.Stat(f); err == nil {
log.Printf("A Taskfile already exists")
os.Exit(1)
return
return ErrTaskfileAlreadyExists
}
}
if err := ioutil.WriteFile("Taskfile.yml", []byte(defaultTaskfile), 0666); err != nil {
log.Fatalf("%v", err)
return err
}
log.Printf("Taskfile.yml created in the current directory")
return nil
}