Skip to content

Commit 760369a

Browse files
committed
feat: add a deprecation warning when running Taskfiles with a v2 schema
1 parent cbb8578 commit 760369a

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

setup.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,11 @@ func (e *Executor) doVersionChecks() error {
250250
*v = *e.Taskfile.Version
251251

252252
if v.LessThan(taskfile.V2) {
253-
return fmt.Errorf(`task: Taskfile versions prior to v2 are not supported anymore`)
253+
return fmt.Errorf(`task: version 1 schemas are no longer supported`)
254+
}
255+
256+
if v.LessThan(taskfile.V3) {
257+
e.Logger.Outf(logger.Yellow, "task: version 2 schemas are deprecated and will be removed in a future release\nSee https://github.com/go-task/task/issues/1197 for more details\n")
254258
}
255259

256260
// consider as equal to the greater version if round

task_test.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -1360,15 +1360,27 @@ func TestDynamicVariablesShouldRunOnTheTaskDir(t *testing.T) {
13601360
tt.Run(t)
13611361
}
13621362

1363-
func TestDisplaysErrorOnUnsupportedVersion(t *testing.T) {
1363+
func TestDisplaysErrorOnVersion1Schema(t *testing.T) {
13641364
e := task.Executor{
13651365
Dir: "testdata/version/v1",
13661366
Stdout: io.Discard,
13671367
Stderr: io.Discard,
13681368
}
13691369
err := e.Setup()
13701370
require.Error(t, err)
1371-
assert.Equal(t, "task: Taskfile versions prior to v2 are not supported anymore", err.Error())
1371+
assert.Equal(t, "task: version 1 schemas are no longer supported", err.Error())
1372+
}
1373+
1374+
func TestDisplaysWarningOnVersion2Schema(t *testing.T) {
1375+
var buff bytes.Buffer
1376+
e := task.Executor{
1377+
Dir: "testdata/version/v2",
1378+
Stdout: &buff,
1379+
Stderr: io.Discard,
1380+
}
1381+
err := e.Setup()
1382+
require.NoError(t, err)
1383+
assert.Equal(t, "task: version 2 schemas are deprecated and will be removed in a future release\nSee https://github.com/go-task/task/issues/1197 for more details\n", buff.String())
13721384
}
13731385

13741386
func TestShortTaskNotation(t *testing.T) {

0 commit comments

Comments
 (0)