From d1360ee72a72996d114cd360c2c520d6130fafd8 Mon Sep 17 00:00:00 2001 From: Pete Davison Date: Tue, 11 Mar 2025 13:53:08 +0000 Subject: [PATCH] refactor: embed the default Taskfile instead of defining it in code (#2112) --- init.go | 18 ++++-------------- taskfile/templates/default.yml | 12 ++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 taskfile/templates/default.yml diff --git a/init.go b/init.go index f5bac631..b377cc3f 100644 --- a/init.go +++ b/init.go @@ -1,28 +1,18 @@ package task import ( + _ "embed" "os" "github.com/go-task/task/v3/errors" "github.com/go-task/task/v3/internal/filepathext" ) -const DefaultTaskfile = `# https://taskfile.dev - -version: '3' - -vars: - GREETING: Hello, World! - -tasks: - default: - cmds: - - echo "{{.GREETING}}" - silent: true -` - const defaultTaskFilename = "Taskfile.yml" +//go:embed taskfile/templates/default.yml +var DefaultTaskfile string + // InitTaskfile creates a new Taskfile at path. // // path can be either a file path or a directory path. diff --git a/taskfile/templates/default.yml b/taskfile/templates/default.yml new file mode 100644 index 00000000..51b2a82a --- /dev/null +++ b/taskfile/templates/default.yml @@ -0,0 +1,12 @@ +# https://taskfile.dev + +version: '3' + +vars: + GREETING: Hello, World! + +tasks: + default: + cmds: + - echo "{{.GREETING}}" + silent: true