Skip to content

Commit

Permalink
Increment the current Taskfile version to 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
andreynering committed Oct 13, 2018
1 parent f519f56 commit 5d9de14
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
20 changes: 18 additions & 2 deletions docs/taskfile_versions.md
Expand Up @@ -128,5 +128,21 @@ tasks:
ignore_error: true
```

[output]: https://github.com/go-task/task#output-syntax
[ignore_errors]: https://github.com/go-task/task#ignore-errors
## Version 2.2

Version 2.2 comes with a global `includes` options to include other
Taskfiles:

```yaml
version: '2'

includes:
docs: ./documentation # will look for ./documentation/Taskfile.yml
docker: ./DockerTasks.yml
```

Please check the [documentation][includes]

[output]: usage#output-syntax
[ignore_errors]: usage#ignore-errors
[includes]: usage#including-other-taskfiles
6 changes: 6 additions & 0 deletions internal/taskfile/version/version.go
Expand Up @@ -9,6 +9,7 @@ var (
v2 = mustVersion("2")
v21 = mustVersion("2.1")
v22 = mustVersion("2.2")
v23 = mustVersion("2.3")
)

// IsV1 returns if is a given Taskfile version is version 1
Expand All @@ -31,6 +32,11 @@ func IsV22(v *semver.Constraints) bool {
return v.Check(v22)
}

// IsV23 returns if is a given Taskfile version is at least version 2.3
func IsV23(v *semver.Constraints) bool {
return v.Check(v23)
}

func mustVersion(s string) *semver.Version {
v, err := semver.NewVersion(s)
if err != nil {
Expand Down
9 changes: 6 additions & 3 deletions task.go
Expand Up @@ -116,21 +116,24 @@ func (e *Executor) Setup() error {
Vars: e.taskvars,
Logger: e.Logger,
}
case version.IsV2(v), version.IsV21(v):
case version.IsV2(v), version.IsV21(v), version.IsV22(v):
e.Compiler = &compilerv2.CompilerV2{
Dir: e.Dir,
Taskvars: e.taskvars,
TaskfileVars: e.Taskfile.Vars,
Expansions: e.Taskfile.Expansions,
Logger: e.Logger,
}
case version.IsV22(v):
return fmt.Errorf(`task: Taskfile versions greater than v2.1 not implemented in the version of Task`)
case version.IsV23(v):
return fmt.Errorf(`task: Taskfile versions greater than v2.3 not implemented in the version of Task`)
}

if !version.IsV21(v) && e.Taskfile.Output != "" {
return fmt.Errorf(`task: Taskfile option "output" is only available starting on Taskfile version v2.1`)
}
if !version.IsV22(v) && len(e.Taskfile.Includes) > 0 {
return fmt.Errorf(`task: Including Taskfiles is only available starting on Taskfile version v2.2`)
}
switch e.Taskfile.Output {
case "", "interleaved":
e.Output = output.Interleaved{}
Expand Down

0 comments on commit 5d9de14

Please sign in to comment.