File tree 4 files changed +10
-10
lines changed
4 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 4
4
5
5
- Made ` --init ` less verbose by default and respect ` --silent ` and ` --verbose `
6
6
flags (#2009 , #2011 by @HeCorr ).
7
+ - ` --init ` now accepts a file name or directory as an argument (#2008 , #2018 by
8
+ @HeCorr ).
7
9
- Fix a bug where an HTTP node's location was being mutated incorrectly (#2007
8
10
by @jeongukjae ).
9
11
- Fixed a bug where allowed values didn't work with dynamic var (#2032 , #2033 by
Original file line number Diff line number Diff line change 4
4
"context"
5
5
"fmt"
6
6
"os"
7
- fp "path/filepath"
7
+ "path/filepath"
8
8
"strings"
9
9
10
10
"github.com/spf13/pflag"
@@ -87,11 +87,11 @@ func run() error {
87
87
if len (args ) > 0 {
88
88
name := args [0 ]
89
89
if filepathext .IsExtOnly (name ) {
90
- name = filepathext .SmartJoin (fp .Dir (name ), "Taskfile" + fp .Ext (name ))
90
+ name = filepathext .SmartJoin (filepath .Dir (name ), "Taskfile" + filepath .Ext (name ))
91
91
}
92
92
path = filepathext .SmartJoin (wd , name )
93
93
}
94
- finalPath , err := task .InitTaskfile (os . Stdout , path )
94
+ finalPath , err := task .InitTaskfile (path )
95
95
if err != nil {
96
96
return err
97
97
}
Original file line number Diff line number Diff line change 1
1
package task
2
2
3
3
import (
4
- "io"
5
4
"os"
6
5
7
6
"github.com/go-task/task/v3/errors"
@@ -22,22 +21,22 @@ tasks:
22
21
silent: true
23
22
`
24
23
25
- const DefaultTaskFilename = "Taskfile.yml"
24
+ const defaultTaskFilename = "Taskfile.yml"
26
25
27
26
// InitTaskfile creates a new Taskfile at path.
28
27
//
29
28
// path can be either a file path or a directory path.
30
29
// If path is a directory, path/Taskfile.yml will be created.
31
30
//
32
31
// The final file path is always returned and may be different from the input path.
33
- func InitTaskfile (w io. Writer , path string ) (string , error ) {
32
+ func InitTaskfile (path string ) (string , error ) {
34
33
fi , err := os .Stat (path )
35
34
if err == nil && ! fi .IsDir () {
36
35
return path , errors.TaskfileAlreadyExistsError {}
37
36
}
38
37
39
38
if fi != nil && fi .IsDir () {
40
- path = filepathext .SmartJoin (path , DefaultTaskFilename )
39
+ path = filepathext .SmartJoin (path , defaultTaskFilename )
41
40
// path was a directory, so check if Taskfile.yml exists in it
42
41
if _ , err := os .Stat (path ); err == nil {
43
42
return path , errors.TaskfileAlreadyExistsError {}
Original file line number Diff line number Diff line change 1
1
package task_test
2
2
3
3
import (
4
- "io"
5
4
"os"
6
5
"testing"
7
6
@@ -20,7 +19,7 @@ func TestInitDir(t *testing.T) {
20
19
t .Errorf ("Taskfile.yml should not exist" )
21
20
}
22
21
23
- if _ , err := task .InitTaskfile (io . Discard , dir ); err != nil {
22
+ if _ , err := task .InitTaskfile (dir ); err != nil {
24
23
t .Error (err )
25
24
}
26
25
@@ -42,7 +41,7 @@ func TestInitFile(t *testing.T) {
42
41
t .Errorf ("Tasks.yml should not exist" )
43
42
}
44
43
45
- if _ , err := task .InitTaskfile (io . Discard , file ); err != nil {
44
+ if _ , err := task .InitTaskfile (file ); err != nil {
46
45
t .Error (err )
47
46
}
48
47
You can’t perform that action at this time.
0 commit comments