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:
10
init.go
10
init.go
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user