mirror of
https://github.com/go-task/task.git
synced 2025-04-19 23:02:17 +03:00
chore: changelog and minor adjustments for #2018
This commit is contained in:
parent
0e23404d23
commit
ff8c913ce7
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
- Made `--init` less verbose by default and respect `--silent` and `--verbose`
|
- Made `--init` less verbose by default and respect `--silent` and `--verbose`
|
||||||
flags (#2009, #2011 by @HeCorr).
|
flags (#2009, #2011 by @HeCorr).
|
||||||
|
- `--init` now accepts a file name or directory as an argument (#2008, #2018 by
|
||||||
|
@HeCorr).
|
||||||
- Fix a bug where an HTTP node's location was being mutated incorrectly (#2007
|
- Fix a bug where an HTTP node's location was being mutated incorrectly (#2007
|
||||||
by @jeongukjae).
|
by @jeongukjae).
|
||||||
- Fixed a bug where allowed values didn't work with dynamic var (#2032, #2033 by
|
- Fixed a bug where allowed values didn't work with dynamic var (#2032, #2033 by
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
fp "path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
@ -87,11 +87,11 @@ func run() error {
|
|||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
name := args[0]
|
name := args[0]
|
||||||
if filepathext.IsExtOnly(name) {
|
if filepathext.IsExtOnly(name) {
|
||||||
name = filepathext.SmartJoin(fp.Dir(name), "Taskfile"+fp.Ext(name))
|
name = filepathext.SmartJoin(filepath.Dir(name), "Taskfile"+filepath.Ext(name))
|
||||||
}
|
}
|
||||||
path = filepathext.SmartJoin(wd, name)
|
path = filepathext.SmartJoin(wd, name)
|
||||||
}
|
}
|
||||||
finalPath, err := task.InitTaskfile(os.Stdout, path)
|
finalPath, err := task.InitTaskfile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
7
init.go
7
init.go
@ -1,7 +1,6 @@
|
|||||||
package task
|
package task
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/go-task/task/v3/errors"
|
"github.com/go-task/task/v3/errors"
|
||||||
@ -22,7 +21,7 @@ tasks:
|
|||||||
silent: true
|
silent: true
|
||||||
`
|
`
|
||||||
|
|
||||||
const DefaultTaskFilename = "Taskfile.yml"
|
const defaultTaskFilename = "Taskfile.yml"
|
||||||
|
|
||||||
// InitTaskfile creates a new Taskfile at path.
|
// InitTaskfile creates a new Taskfile at path.
|
||||||
//
|
//
|
||||||
@ -30,14 +29,14 @@ const DefaultTaskFilename = "Taskfile.yml"
|
|||||||
// If path is a directory, path/Taskfile.yml will be created.
|
// If path is a directory, path/Taskfile.yml will be created.
|
||||||
//
|
//
|
||||||
// The final file path is always returned and may be different from the input path.
|
// The final file path is always returned and may be different from the input path.
|
||||||
func InitTaskfile(w io.Writer, path string) (string, error) {
|
func InitTaskfile(path string) (string, error) {
|
||||||
fi, err := os.Stat(path)
|
fi, err := os.Stat(path)
|
||||||
if err == nil && !fi.IsDir() {
|
if err == nil && !fi.IsDir() {
|
||||||
return path, errors.TaskfileAlreadyExistsError{}
|
return path, errors.TaskfileAlreadyExistsError{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if fi != nil && fi.IsDir() {
|
if fi != nil && fi.IsDir() {
|
||||||
path = filepathext.SmartJoin(path, DefaultTaskFilename)
|
path = filepathext.SmartJoin(path, defaultTaskFilename)
|
||||||
// path was a directory, so check if Taskfile.yml exists in it
|
// path was a directory, so check if Taskfile.yml exists in it
|
||||||
if _, err := os.Stat(path); err == nil {
|
if _, err := os.Stat(path); err == nil {
|
||||||
return path, errors.TaskfileAlreadyExistsError{}
|
return path, errors.TaskfileAlreadyExistsError{}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package task_test
|
package task_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -20,7 +19,7 @@ func TestInitDir(t *testing.T) {
|
|||||||
t.Errorf("Taskfile.yml should not exist")
|
t.Errorf("Taskfile.yml should not exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := task.InitTaskfile(io.Discard, dir); err != nil {
|
if _, err := task.InitTaskfile(dir); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +41,7 @@ func TestInitFile(t *testing.T) {
|
|||||||
t.Errorf("Tasks.yml should not exist")
|
t.Errorf("Tasks.yml should not exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := task.InitTaskfile(io.Discard, file); err != nil {
|
if _, err := task.InitTaskfile(file); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user