mirror of
https://github.com/go-task/task.git
synced 2025-02-11 13:53:03 +02:00
parent
b8fe8d465e
commit
e1fc3aa4fb
@ -39,9 +39,7 @@ your `PATH`. DEB and RPM packages are also available.
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Create a file called `Taskfile.yml` in the root of the project.
|
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 `cmds` attribute should contains the commands of a task:
|
||||||
the documentation). The `cmds` attribute should contains the commands of a
|
|
||||||
task:
|
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
build:
|
build:
|
||||||
@ -256,7 +254,7 @@ setvar:
|
|||||||
The above sample saves the path into a new variable which is then again echoed.
|
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
|
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:
|
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
|
package task
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
|
||||||
"github.com/imdario/mergo"
|
"github.com/imdario/mergo"
|
||||||
"gopkg.in/yaml.v2"
|
"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 {
|
if b, err := ioutil.ReadFile(path + ".yml"); err == nil {
|
||||||
return tasks, yaml.Unmarshal(b, &tasks)
|
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}
|
return nil, taskFileNotFound{path}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,19 +51,6 @@ func (e *Executor) readTaskvarsFile() error {
|
|||||||
if err := yaml.Unmarshal(b, &e.taskvars); err != nil {
|
if err := yaml.Unmarshal(b, &e.taskvars); err != nil {
|
||||||
return err
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user