Skip to content

Commit 1d7982e

Browse files
committed
fix(#584): Add support to yaml extension
- init creates Taskfile.yaml - add changelog entry - add zsh completion support for Taskfile.yaml
1 parent 17e1844 commit 1d7982e

File tree

21 files changed

+211
-87
lines changed

21 files changed

+211
-87
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
name: Bug Report
33
about: Use the template to report bugs and issues
4-
labels: bug
54
---
65

76
- Task version:

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
name: Feature Request
33
about: Use the template to make feature requests
4-
labels: feature
54
---
65

76
Describe in detail what feature do you want to see in Task.

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v1
13+
uses: actions/checkout@v2
1414

1515
- name: Set up Go
16-
uses: actions/setup-go@v1
16+
uses: actions/setup-go@v2
1717
with:
1818
go-version: 1.17.x
1919

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ jobs:
1010
runs-on: ${{matrix.platform}}
1111
steps:
1212
- name: Set up Go ${{matrix.go-version}}
13-
uses: actions/setup-go@v1
13+
uses: actions/setup-go@v2
1414
with:
1515
go-version: ${{matrix.go-version}}
1616
id: go
1717

1818
- name: Check out code into the Go module directory
19-
uses: actions/checkout@v1
19+
uses: actions/checkout@v2
2020

2121
- name: Download Go modules
2222
run: go mod download

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22

33
## Unreleased
44

5+
- Add support for yaml extension ([#584](https://github.com/go-task/task/issues/584))
6+
7+
## v3.9.2 - 2021-12-02
8+
9+
- Upgrade [mvdan/sh](https://github.com/mvdan/sh) which contains a fix a for
10+
a important regression on Windows
11+
([#619](https://github.com/go-task/task/issues/619), [mvdan/sh#768](https://github.com/mvdan/sh/issues/768), [mvdan/sh#769](https://github.com/mvdan/sh/pull/769)).
12+
13+
## v3.9.1 - 2021-11-28
14+
15+
- Add logging in verbose mode for when a task starts and finishes
16+
([#533](https://github.com/go-task/task/issues/533), [#588](https://github.com/go-task/task/pull/588)).
17+
- Fix an issue with preconditions and context errors
18+
([#597](https://github.com/go-task/task/issues/597), [#598](https://github.com/go-task/task/pull/598)).
19+
- Quote each `{{.CLI_ARGS}}` argument to prevent one with spaces to become many
20+
([#613](https://github.com/go-task/task/pull/613)).
21+
- Fix nil pointer when `cmd:` was left empty
22+
([#612](https://github.com/go-task/task/issues/612), [#614](https://github.com/go-task/task/pull/614)).
23+
- Upgrade [mvdan/sh](https://github.com/mvdan/sh) which contains two
24+
relevant fixes:
25+
- Fix quote of empty strings in `shellQuote`
26+
([#609](https://github.com/go-task/task/issues/609), [mvdan/sh#763](https://github.com/mvdan/sh/issues/763)).
27+
- Fix issue of wrong environment variable being picked when there's another
28+
very similar one
29+
([#586](https://github.com/go-task/task/issues/586), [mvdan/sh#745](https://github.com/mvdan/sh/pull/745)).
530
- Install shell completions automatically when installing via Homebrew
631
([#264](https://github.com/go-task/task/issues/264), [#592](https://github.com/go-task/task/pull/592), [go-task/homebrew-tap#2](https://github.com/go-task/homebrew-tap/pull/2)).
732

cmd/task/task.go

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"syscall"
1313

1414
"github.com/spf13/pflag"
15+
"mvdan.cc/sh/v3/syntax"
1516

1617
"github.com/go-task/task/v3"
1718
"github.com/go-task/task/v3/args"
@@ -76,7 +77,7 @@ func main() {
7677

7778
pflag.BoolVar(&versionFlag, "version", false, "show Task version")
7879
pflag.BoolVarP(&helpFlag, "help", "h", false, "shows Task usage")
79-
pflag.BoolVarP(&init, "init", "i", false, "creates a new Taskfile.yml in the current folder")
80+
pflag.BoolVarP(&init, "init", "i", false, "creates a new Taskfile.yaml in the current folder")
8081
pflag.BoolVarP(&list, "list", "l", false, "lists tasks with description of current Taskfile")
8182
pflag.BoolVar(&status, "status", false, "exits with non-zero exit code if any of the given tasks is not up-to-date")
8283
pflag.BoolVarP(&force, "force", "f", false, "forces execution even when the task is up-to-date")
@@ -121,8 +122,6 @@ func main() {
121122
if entrypoint != "" {
122123
dir = filepath.Dir(entrypoint)
123124
entrypoint = filepath.Base(entrypoint)
124-
} else {
125-
entrypoint = "Taskfile.yml"
126125
}
127126

128127
e := task.Executor{
@@ -159,18 +158,22 @@ func main() {
159158
}
160159

161160
var (
162-
calls []taskfile.Call
163-
globals *taskfile.Vars
164-
tasksAndVars, cliArgs = getArgs()
161+
calls []taskfile.Call
162+
globals *taskfile.Vars
165163
)
166164

165+
tasksAndVars, cliArgs, err := getArgs()
166+
if err != nil {
167+
log.Fatal(err)
168+
}
169+
167170
if v >= 3.0 {
168171
calls, globals = args.ParseV3(tasksAndVars...)
169172
} else {
170173
calls, globals = args.ParseV2(tasksAndVars...)
171174
}
172175

173-
globals.Set("CLI_ARGS", taskfile.Var{Static: strings.Join(cliArgs, " ")})
176+
globals.Set("CLI_ARGS", taskfile.Var{Static: cliArgs})
174177
e.Taskfile.Vars.Merge(globals)
175178

176179
ctx := context.Background()
@@ -191,20 +194,25 @@ func main() {
191194
}
192195
}
193196

194-
func getArgs() (tasksAndVars, cliArgs []string) {
197+
func getArgs() ([]string, string, error) {
195198
var (
196199
args = pflag.Args()
197200
doubleDashPos = pflag.CommandLine.ArgsLenAtDash()
198201
)
199202

200-
if doubleDashPos != -1 {
201-
tasksAndVars = args[:doubleDashPos]
202-
cliArgs = args[doubleDashPos:]
203-
} else {
204-
tasksAndVars = args
203+
if doubleDashPos == -1 {
204+
return args, "", nil
205205
}
206206

207-
return
207+
var quotedCliArgs []string
208+
for _, arg := range args[doubleDashPos:] {
209+
quotedCliArg, err := syntax.Quote(arg, syntax.LangBash)
210+
if err != nil {
211+
return nil, "", err
212+
}
213+
quotedCliArgs = append(quotedCliArgs, quotedCliArg)
214+
}
215+
return args[:doubleDashPos], strings.Join(quotedCliArgs, " "), nil
208216
}
209217

210218
func getSignalContext() context.Context {

completion/zsh/_task

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
function __list() {
55
local -a scripts
66

7-
if [ -f Taskfile.yml ]; then
7+
if [ -f Taskfile.yml ] || [ -f Taskfile.yaml ]; then
88
scripts=($(task -l | sed '1d' | sed 's/^\* //' | awk '{ print $1 }' | sed 's/:$//' | sed 's/:/\\:/g'))
99
_describe 'script' scripts
1010
fi

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/stretchr/testify v1.7.0
1212
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
1313
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
14-
mvdan.cc/sh/v3 v3.4.0
14+
mvdan.cc/sh/v3 v3.4.2-0.20211202103622-5ae9d64e1402
1515
)
1616

1717
go 1.16

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
6868
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
6969
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
7070
mvdan.cc/editorconfig v0.2.0/go.mod h1:lvnnD3BNdBYkhq+B4uBuFFKatfp02eB6HixDvEz91C0=
71-
mvdan.cc/sh/v3 v3.4.0 h1:thPCJ0hffn/Y/vMGs3HVMPYStNTyr2+lQee8LQiPZSU=
72-
mvdan.cc/sh/v3 v3.4.0/go.mod h1:p/tqPPI4Epfk2rICAe2RoaNd8HBSJ8t9Y2DA9yQlbzY=
71+
mvdan.cc/sh/v3 v3.4.2-0.20211202103622-5ae9d64e1402 h1:IhYcaLRZjSJqGoLrn+sXXFq3Xhd40I0wBkoIyg6cSZs=
72+
mvdan.cc/sh/v3 v3.4.2-0.20211202103622-5ae9d64e1402/go.mod h1:p/tqPPI4Epfk2rICAe2RoaNd8HBSJ8t9Y2DA9yQlbzY=

init.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package task
33
import (
44
"fmt"
55
"io"
6-
"io/ioutil"
76
"os"
87
"path/filepath"
98
)
@@ -24,15 +23,15 @@ tasks:
2423

2524
// InitTaskfile Taskfile creates a new Taskfile
2625
func InitTaskfile(w io.Writer, dir string) error {
27-
f := filepath.Join(dir, "Taskfile.yml")
26+
f := filepath.Join(dir, "Taskfile.yaml")
2827

2928
if _, err := os.Stat(f); err == nil {
3029
return ErrTaskfileAlreadyExists
3130
}
3231

33-
if err := ioutil.WriteFile(f, []byte(defaultTaskfile), 0644); err != nil {
32+
if err := os.WriteFile(f, []byte(defaultTaskfile), 0644); err != nil {
3433
return err
3534
}
36-
fmt.Fprintf(w, "Taskfile.yml created in the current directory\n")
35+
fmt.Fprintf(w, "Taskfile.yaml created in the current directory\n")
3736
return nil
3837
}

0 commit comments

Comments
 (0)