mirror of
https://github.com/go-task/task.git
synced 2024-12-12 10:45:49 +02:00
7c02097d93
- Update generated Taskfile to version 2 - Don't loop anymore on extensions since we only support YAML - Use 644 for file permission
39 lines
642 B
Go
39 lines
642 B
Go
package task
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
const defaultTaskfile = `# github.com/go-task/task
|
|
|
|
version: '2'
|
|
|
|
vars:
|
|
GREETING: Hello, World!
|
|
|
|
tasks:
|
|
default:
|
|
cmds:
|
|
- echo "{{.GREETING}}"
|
|
silent: true
|
|
`
|
|
|
|
// InitTaskfile Taskfile creates a new Taskfile
|
|
func InitTaskfile(w io.Writer, dir string) error {
|
|
f := filepath.Join(dir, "Taskfile.yml")
|
|
|
|
if _, err := os.Stat(f); err == nil {
|
|
return ErrTaskfileAlreadyExists
|
|
}
|
|
|
|
if err := ioutil.WriteFile(f, []byte(defaultTaskfile), 0644); err != nil {
|
|
return err
|
|
}
|
|
fmt.Fprintf(w, "Taskfile.yml created in the current directory\n")
|
|
return nil
|
|
}
|