Skip to content

Commit d5a791b

Browse files
committed
Merge branch 'master' into v3
2 parents e625508 + a312d61 commit d5a791b

File tree

7 files changed

+62
-27
lines changed

7 files changed

+62
-27
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,21 @@
99

1010
## Unreleased
1111

12+
- Fixed panic bug when assigning a global variable
13+
([#229](https://github.com/go-task/task/issues/229), [#243](https://github.com/go-task/task/issues/234)).
14+
15+
## v2.6.0 - 2019-07-21
16+
1217
- Fixed some bugs regarding minor version checks on `version:`.
1318
- Add `preconditions:` to task
1419
([#205](https://github.com/go-task/task/pull/205)).
1520
- Create directory informed on `dir:` if it doesn't exist
1621
([#209](https://github.com/go-task/task/issues/209), [#211](https://github.com/go-task/task/pull/211)).
22+
- We now have a `--taskfile` flag (alias `-t`), which can be used to run
23+
another Taskfile (other than the default `Taskfile.yml`)
24+
([#221](https://github.com/go-task/task/pull/221)).
25+
- It's now possible to install Task using Homebrew on Linux
26+
([go-task/homebrew-tap#1](https://github.com/go-task/homebrew-tap/pull/1)).
1727

1828
## v2.5.2 - 2019-05-11
1929

cmd/task/task.go

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"log"
66
"os"
77
"os/signal"
8+
"path/filepath"
89
"syscall"
910

1011
"github.com/go-task/task/v2"
@@ -18,7 +19,7 @@ var (
1819
version = "master"
1920
)
2021

21-
const usage = `Usage: task [-ilfwvsd] [--init] [--list] [--force] [--watch] [--verbose] [--silent] [--dir] [--dry] [--summary] [task...]
22+
const usage = `Usage: task [-ilfwvsd] [--init] [--list] [--force] [--watch] [--verbose] [--silent] [--dir] [--taskfile] [--dry] [--summary] [task...]
2223
2324
Runs the specified task(s). Falls back to the "default" task if no task name
2425
was specified, or lists all tasks if an unknown task name was specified.
@@ -59,6 +60,7 @@ func main() {
5960
dry bool
6061
summary bool
6162
dir string
63+
entrypoint string
6264
output string
6365
color bool
6466
)
@@ -74,6 +76,7 @@ func main() {
7476
pflag.BoolVar(&dry, "dry", false, "compiles and prints tasks in the order that they would be run, without executing them")
7577
pflag.BoolVar(&summary, "summary", false, "show summary about a task")
7678
pflag.StringVarP(&dir, "dir", "d", "", "sets directory of execution")
79+
pflag.StringVarP(&entrypoint, "taskfile", "t", "", `choose which Taskfile to run. Defaults to "Taskfile.yml"`)
7780
pflag.StringVarP(&output, "output", "o", "", "sets output style: [interleaved|group|prefixed]")
7881
pflag.BoolVarP(&color, "color", "c", true, "colored output")
7982
pflag.Parse()
@@ -94,15 +97,27 @@ func main() {
9497
return
9598
}
9699

100+
if dir != "" && entrypoint != "" {
101+
log.Fatal("task: You can't set both --dir and --taskfile")
102+
return
103+
}
104+
if entrypoint != "" {
105+
dir = filepath.Dir(entrypoint)
106+
entrypoint = filepath.Base(entrypoint)
107+
} else {
108+
entrypoint = "Taskfile.yml"
109+
}
110+
97111
e := task.Executor{
98-
Force: force,
99-
Watch: watch,
100-
Verbose: verbose,
101-
Silent: silent,
102-
Dir: dir,
103-
Dry: dry,
104-
Summary: summary,
105-
Color: color,
112+
Force: force,
113+
Watch: watch,
114+
Verbose: verbose,
115+
Silent: silent,
116+
Dir: dir,
117+
Dry: dry,
118+
Entrypoint: entrypoint,
119+
Summary: summary,
120+
Color: color,
106121

107122
Stdin: os.Stdin,
108123
Stdout: os.Stdout,

docs/installation.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ The `task_checksums.txt` file contains the sha256 checksum for each file.
88

99
## Homebrew
1010

11-
If you're on macOS and have [Homebrew][homebrew] installed, getting Task is
12-
as simple as running:
11+
If you're on macOS or Linux and have [Homebrew][homebrew] installed, getting
12+
Task is as simple as running:
1313

1414
```bash
1515
brew install go-task/tap/go-task
1616
```
1717

18+
> This installation method is only currently supported on amd64 architectures.
19+
1820
## Snap
1921

2022
Task is available for [Snapcraft][snapcraft], but keep in mind that your

docs/usage.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ tasks:
148148
- caddy
149149
```
150150

151+
If the directory doesn't exist, `task` creates it.
152+
151153
## Task dependencies
152154

153155
You may have tasks that depend on others. Just pointing them on `deps` will
@@ -398,7 +400,7 @@ tasks:
398400
When doing interpolation of variables, Task will look for the below.
399401
They are listed below in order of importance (e.g. most important first):
400402

401-
- Variables declared locally in the task
403+
- Variables declared in the task definition
402404
- Variables given while calling a task from another.
403405
(See [Calling another task](#calling-another-task) above)
404406
- Variables declared in the `vars:` option in the `Taskfile`

internal/taskfile/read/taskfile.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@ import (
1515
var (
1616
// ErrIncludedTaskfilesCantHaveIncludes is returned when a included Taskfile contains includes
1717
ErrIncludedTaskfilesCantHaveIncludes = errors.New("task: Included Taskfiles can't have includes. Please, move the include to the main Taskfile")
18-
19-
// ErrNoTaskfileFound is returned when Taskfile.yml is not found
20-
ErrNoTaskfileFound = errors.New(`task: No Taskfile.yml found. Use "task --init" to create a new one`)
2118
)
2219

2320
// Taskfile reads a Taskfile for a given directory
24-
func Taskfile(dir string) (*taskfile.Taskfile, error) {
25-
path := filepath.Join(dir, "Taskfile.yml")
21+
func Taskfile(dir string, entrypoint string) (*taskfile.Taskfile, error) {
22+
path := filepath.Join(dir, entrypoint)
2623
if _, err := os.Stat(path); err != nil {
27-
return nil, ErrNoTaskfileFound
24+
return nil, fmt.Errorf(`task: No Taskfile found on "%s". Use "task --init" to create a new one`, path)
2825
}
2926
t, err := readTaskfile(path)
3027
if err != nil {

internal/taskfile/taskfile.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,8 @@ func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error {
4040
if tf.Expansions <= 0 {
4141
tf.Expansions = 2
4242
}
43+
if tf.Vars == nil {
44+
tf.Vars = make(Vars)
45+
}
4346
return nil
4447
}

task.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ const (
3232
// Executor executes a Taskfile
3333
type Executor struct {
3434
Taskfile *taskfile.Taskfile
35-
Dir string
36-
Force bool
37-
Watch bool
38-
Verbose bool
39-
Silent bool
40-
Dry bool
41-
Summary bool
42-
Color bool
35+
36+
Dir string
37+
Entrypoint string
38+
Force bool
39+
Watch bool
40+
Verbose bool
41+
Silent bool
42+
Dry bool
43+
Summary bool
44+
Color bool
4345

4446
Stdin io.Reader
4547
Stdout io.Writer
@@ -86,8 +88,12 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error {
8688

8789
// Setup setups Executor's internal state
8890
func (e *Executor) Setup() error {
91+
if e.Entrypoint == "" {
92+
e.Entrypoint = "Taskfile.yml"
93+
}
94+
8995
var err error
90-
e.Taskfile, err = read.Taskfile(e.Dir)
96+
e.Taskfile, err = read.Taskfile(e.Dir, e.Entrypoint)
9197
if err != nil {
9298
return err
9399
}

0 commit comments

Comments
 (0)