mirror of
https://github.com/go-task/task.git
synced 2024-12-12 10:45:49 +02:00
f98bf6c4b1
Maybe eventually help on #17
30 lines
570 B
Go
30 lines
570 B
Go
package task
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
const defaultTaskfile = `# github.com/go-task/task
|
|
|
|
default:
|
|
cmds:
|
|
- echo "Hello, World!"
|
|
`
|
|
|
|
// 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 {
|
|
return ErrTaskfileAlreadyExists
|
|
}
|
|
}
|
|
|
|
if err := ioutil.WriteFile("Taskfile.yml", []byte(defaultTaskfile), 0666); err != nil {
|
|
return err
|
|
}
|
|
log.Printf("Taskfile.yml created in the current directory")
|
|
return nil
|
|
}
|