mirror of
https://github.com/go-task/task.git
synced 2026-02-24 12:10:47 +01:00
fix: print prefix when task is up-to-date and output-style is prefixed (#2633)
This commit is contained in:
@@ -717,6 +717,27 @@ func TestLabel(t *testing.T) {
|
||||
)
|
||||
}
|
||||
|
||||
func TestPrefix(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
NewExecutorTest(t,
|
||||
WithName("up to date"),
|
||||
WithExecutorOptions(
|
||||
task.WithDir("testdata/prefix_uptodate"),
|
||||
task.WithOutputStyle(ast.Output{Name: "prefixed"}),
|
||||
),
|
||||
WithTask("foo"),
|
||||
)
|
||||
|
||||
NewExecutorTest(t,
|
||||
WithName("up to dat with no output style"),
|
||||
WithExecutorOptions(
|
||||
task.WithDir("testdata/prefix_uptodate"),
|
||||
),
|
||||
WithTask("foo"),
|
||||
)
|
||||
}
|
||||
|
||||
func TestPromptInSummary(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
6
task.go
6
task.go
@@ -186,7 +186,11 @@ func (e *Executor) RunTask(ctx context.Context, call *Call) error {
|
||||
|
||||
if upToDate && preCondMet {
|
||||
if e.Verbose || (!call.Silent && !t.Silent && !e.Taskfile.Silent && !e.Silent) {
|
||||
e.Logger.Errf(logger.Magenta, "task: Task %q is up to date\n", t.Name())
|
||||
name := t.Name()
|
||||
if e.OutputStyle.Name == "prefixed" {
|
||||
name = t.Prefix
|
||||
}
|
||||
e.Logger.Errf(logger.Magenta, "task: Task %q is up to date\n", name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
7
testdata/prefix_uptodate/Taskfile.yml
vendored
Normal file
7
testdata/prefix_uptodate/Taskfile.yml
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
foo:
|
||||
prefix: "foobar"
|
||||
status:
|
||||
- echo "I'm ok"
|
||||
1
testdata/prefix_uptodate/testdata/TestPrefix-up_to_dat_with_no_output_style.golden
vendored
Normal file
1
testdata/prefix_uptodate/testdata/TestPrefix-up_to_dat_with_no_output_style.golden
vendored
Normal file
@@ -0,0 +1 @@
|
||||
task: Task "foo" is up to date
|
||||
1
testdata/prefix_uptodate/testdata/TestPrefix-up_to_date.golden
vendored
Normal file
1
testdata/prefix_uptodate/testdata/TestPrefix-up_to_date.golden
vendored
Normal file
@@ -0,0 +1 @@
|
||||
task: Task "foobar" is up to date
|
||||
Reference in New Issue
Block a user