mirror of
				https://github.com/go-task/task.git
				synced 2025-10-30 23:58:01 +02:00 
			
		
		
		
	| @@ -39,9 +39,7 @@ your `PATH`. DEB and RPM packages are also available. | ||||
| ## Usage | ||||
|  | ||||
| Create a file called `Taskfile.yml` in the root of the project. | ||||
| (`Taskfile.toml` and `Taskfile.json` are also supported, but YAML is used in | ||||
| the documentation). The `cmds` attribute should contains the commands of a | ||||
| task: | ||||
| The `cmds` attribute should contains the commands of a task: | ||||
|  | ||||
| ```yml | ||||
| build: | ||||
| @@ -256,7 +254,7 @@ setvar: | ||||
| The above sample saves the path into a new variable which is then again echoed. | ||||
|  | ||||
| You can use environment variables, task level variables and a file called | ||||
| `Taskvars.yml` (or `Taskvars.toml` or `Taskvars.json`) as source of variables. | ||||
| `Taskvars.yml` as source of variables. | ||||
|  | ||||
| They are evaluated in the following order: | ||||
|  | ||||
|   | ||||
| @@ -1,11 +0,0 @@ | ||||
| { | ||||
|   "hello": { | ||||
|     "cmds": [ | ||||
|       "echo \"I am going to write a file named 'output.txt' now.\"", | ||||
|       "echo \"hello\" > output.txt" | ||||
|     ], | ||||
|     "generates": [ | ||||
|       "output.txt" | ||||
|     ] | ||||
|   } | ||||
| } | ||||
| @@ -1,6 +0,0 @@ | ||||
| [hello] | ||||
| cmds = [ | ||||
|   "echo \"I am going to write a file named 'output.txt' now.\"", | ||||
|   "echo \"hello\" > output.txt" | ||||
| ] | ||||
| generates = ["output.txt"] | ||||
| @@ -1,13 +1,11 @@ | ||||
| package task | ||||
|  | ||||
| import ( | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"io/ioutil" | ||||
| 	"path/filepath" | ||||
| 	"runtime" | ||||
|  | ||||
| 	"github.com/BurntSushi/toml" | ||||
| 	"github.com/imdario/mergo" | ||||
| 	"gopkg.in/yaml.v2" | ||||
| ) | ||||
| @@ -43,12 +41,6 @@ func (e *Executor) readTaskfileData(path string) (tasks map[string]*Task, err er | ||||
| 	if b, err := ioutil.ReadFile(path + ".yml"); err == nil { | ||||
| 		return tasks, yaml.Unmarshal(b, &tasks) | ||||
| 	} | ||||
| 	if b, err := ioutil.ReadFile(path + ".json"); err == nil { | ||||
| 		return tasks, json.Unmarshal(b, &tasks) | ||||
| 	} | ||||
| 	if b, err := ioutil.ReadFile(path + ".toml"); err == nil { | ||||
| 		return tasks, toml.Unmarshal(b, &tasks) | ||||
| 	} | ||||
| 	return nil, taskFileNotFound{path} | ||||
| } | ||||
|  | ||||
| @@ -59,19 +51,6 @@ func (e *Executor) readTaskvarsFile() error { | ||||
| 		if err := yaml.Unmarshal(b, &e.taskvars); err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		return nil | ||||
| 	} | ||||
| 	if b, err := ioutil.ReadFile(file + ".json"); err == nil { | ||||
| 		if err := json.Unmarshal(b, &e.taskvars); err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		return nil | ||||
| 	} | ||||
| 	if b, err := ioutil.ReadFile(file + ".toml"); err == nil { | ||||
| 		if err := toml.Unmarshal(b, &e.taskvars); err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		return nil | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user