-
-
Notifications
You must be signed in to change notification settings - Fork 639
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make Taskfile initialization less verbose by default (#2011)
* change what is printed when creating Taskfile When using --init to create a new Taskfile, it used to print the whole contents of the file to the terminal, which was unnecessarily verbose (and honestly felt unintentional). Now only the filename is printed by default and the --silent and --verbose flags can be used to control the behavior (print nothing or content + filename, respectively). * include additional new line with -i -v it looks slightly better in the terminal. * print init success text in green * fix TestInit, create and pass in a logger * move logging outside of InitTaskfile - revert API changes made to InitTaskfile - make consts in init.go public so they can be accessed from task.go - rename variable "logger" to "log" in task.go to fix conflict with logger package * move TestInit into init_test.go file as requested by pd93.
- Loading branch information
Showing
4 changed files
with
49 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package task_test | ||
|
||
import ( | ||
"io" | ||
"os" | ||
"testing" | ||
|
||
"github.com/go-task/task/v3" | ||
"github.com/go-task/task/v3/internal/filepathext" | ||
) | ||
|
||
func TestInit(t *testing.T) { | ||
t.Parallel() | ||
|
||
const dir = "testdata/init" | ||
file := filepathext.SmartJoin(dir, "Taskfile.yml") | ||
|
||
_ = os.Remove(file) | ||
if _, err := os.Stat(file); err == nil { | ||
t.Errorf("Taskfile.yml should not exist") | ||
} | ||
|
||
if err := task.InitTaskfile(io.Discard, dir); err != nil { | ||
t.Error(err) | ||
} | ||
|
||
if _, err := os.Stat(file); err != nil { | ||
t.Errorf("Taskfile.yml should exist") | ||
} | ||
_ = os.Remove(file) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters