mirror of
https://github.com/go-task/task.git
synced 2025-08-10 22:42:19 +02:00
change all tests to call functions instead of binary directly
I had to temporarely hack github.com/mvdan/sh to fix dir handling
This commit is contained in:
7
init.go
7
init.go
@@ -4,6 +4,7 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
const defaultTaskfile = `# github.com/go-task/task
|
||||
@@ -14,14 +15,16 @@ default:
|
||||
`
|
||||
|
||||
// InitTaskfile Taskfile creates a new Taskfile
|
||||
func InitTaskfile() error {
|
||||
func InitTaskfile(path string) error {
|
||||
for _, f := range []string{"Taskfile.yml", "Taskfile.toml", "Taskfile.json"} {
|
||||
f = filepath.Join(path, f)
|
||||
if _, err := os.Stat(f); err == nil {
|
||||
return ErrTaskfileAlreadyExists
|
||||
}
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile("Taskfile.yml", []byte(defaultTaskfile), 0666); err != nil {
|
||||
f := filepath.Join(path, "Taskfile.yml")
|
||||
if err := ioutil.WriteFile(f, []byte(defaultTaskfile), 0666); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("Taskfile.yml created in the current directory")
|
||||
|
Reference in New Issue
Block a user