mirror of
https://github.com/go-task/task.git
synced 2025-03-19 21:17:46 +02:00
parent
21e66c7c02
commit
f8a6c5d06c
@ -72,6 +72,7 @@ func IsExitError(err error) bool {
|
||||
// Expand is a helper to mvdan.cc/shell.Fields that returns the first field
|
||||
// if available.
|
||||
func Expand(s string) (string, error) {
|
||||
s = strings.Replace(s, " ", `\ `, -1)
|
||||
fields, err := shell.Fields(s, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
13
task_test.go
13
task_test.go
@ -274,16 +274,19 @@ func TestStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGenerates(t *testing.T) {
|
||||
var srcTask = "sub/src.txt"
|
||||
var relTask = "rel.txt"
|
||||
var absTask = "abs.txt"
|
||||
const (
|
||||
srcTask = "sub/src.txt"
|
||||
relTask = "rel.txt"
|
||||
absTask = "abs.txt"
|
||||
fileWithSpaces = "my text file.txt"
|
||||
)
|
||||
|
||||
// This test does not work with a relative dir.
|
||||
dir, err := filepath.Abs("testdata/generates")
|
||||
assert.NoError(t, err)
|
||||
var srcFile = filepath.Join(dir, srcTask)
|
||||
|
||||
for _, task := range []string{srcTask, relTask, absTask} {
|
||||
for _, task := range []string{srcTask, relTask, absTask, fileWithSpaces} {
|
||||
path := filepath.Join(dir, task)
|
||||
_ = os.Remove(path)
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
@ -299,7 +302,7 @@ func TestGenerates(t *testing.T) {
|
||||
}
|
||||
assert.NoError(t, e.Setup())
|
||||
|
||||
for _, theTask := range []string{relTask, absTask} {
|
||||
for _, theTask := range []string{relTask, absTask, fileWithSpaces} {
|
||||
var destFile = filepath.Join(dir, theTask)
|
||||
var upToDate = fmt.Sprintf("task: Task \"%s\" is up to date\n", srcTask) +
|
||||
fmt.Sprintf("task: Task \"%s\" is up to date\n", theTask)
|
||||
|
10
testdata/generates/Taskfile.yml
vendored
10
testdata/generates/Taskfile.yml
vendored
@ -29,3 +29,13 @@ sub/src.txt:
|
||||
- echo "hello world" > sub/src.txt
|
||||
status:
|
||||
- test -f sub/src.txt
|
||||
|
||||
'my text file.txt':
|
||||
desc: generate file with spaces in the name
|
||||
deps: [sub/src.txt]
|
||||
cmds:
|
||||
- cat sub/src.txt > 'my text file.txt'
|
||||
sources:
|
||||
- sub/src.txt
|
||||
generates:
|
||||
- 'my text file.txt'
|
||||
|
Loading…
x
Reference in New Issue
Block a user