mirror of
				https://github.com/go-task/task.git
				synced 2025-10-30 23:58:01 +02:00 
			
		
		
		
	Make --init generate .yml instead of .yaml (#1062)
				
					
				
			This commit is contained in:
		
							
								
								
									
										15
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								CHANGELOG.md
									
									
									
									
									
								
							| @@ -2,6 +2,9 @@ | ||||
|  | ||||
| ## Unreleased | ||||
|  | ||||
| - Change the name of the file generated by `task --init` from `Taskfile.yaml` | ||||
|   to `Taskfile.yml` | ||||
|   ([#1062](https://github.com/go-task/task/pull/1062) by @misitebao). | ||||
| - Added new `splitArgs` to the template system | ||||
|   (`{{splitArgs "foo bar 'foo bar baz'"}}`) to ensure string is splitted as | ||||
|   arguments not whitespaces | ||||
| @@ -235,7 +238,7 @@ | ||||
|   ([#597](https://github.com/go-task/task/issues/597), [#598](https://github.com/go-task/task/pull/598)). | ||||
| - Quote each `{{.CLI_ARGS}}` argument to prevent one with spaces to become many | ||||
|   ([#613](https://github.com/go-task/task/pull/613)). | ||||
| - Fix  nil pointer when `cmd:` was left empty | ||||
| - Fix nil pointer when `cmd:` was left empty | ||||
|   ([#612](https://github.com/go-task/task/issues/612), [#614](https://github.com/go-task/task/pull/614)). | ||||
| - Upgrade [mvdan/sh](https://github.com/mvdan/sh) which contains two | ||||
|   relevant fixes: | ||||
| @@ -532,8 +535,8 @@ | ||||
|   ([#153](https://github.com/go-task/task/issues/153)); | ||||
| - Added ability to globally set environment variables | ||||
|   ( | ||||
|     [#138](https://github.com/go-task/task/pull/138), | ||||
|     [#159](https://github.com/go-task/task/pull/159) | ||||
|   [#138](https://github.com/go-task/task/pull/138), | ||||
|   [#159](https://github.com/go-task/task/pull/159) | ||||
|   ). | ||||
|  | ||||
| ## v2.2.1 - 2018-12-09 | ||||
| @@ -581,9 +584,9 @@ Version 2.0.0 is here, with a new Taskfile format. | ||||
|  | ||||
| Please, make sure to read the [Taskfile versions](https://github.com/go-task/task/blob/master/TASKFILE_VERSIONS.md) document, since it describes in depth what changed for this version. | ||||
|  | ||||
| * New Taskfile version 2 (https://github.com/go-task/task/issues/77) | ||||
| * Possibility to have global variables in the `Taskfile.yml` instead of `Taskvars.yml` (https://github.com/go-task/task/issues/66) | ||||
| * Small improvements and fixes | ||||
| - New Taskfile version 2 (https://github.com/go-task/task/issues/77) | ||||
| - Possibility to have global variables in the `Taskfile.yml` instead of `Taskvars.yml` (https://github.com/go-task/task/issues/66) | ||||
| - Small improvements and fixes | ||||
|  | ||||
| ## v1.4.4 - 2017-11-19 | ||||
|  | ||||
|   | ||||
| @@ -77,7 +77,7 @@ func main() { | ||||
|  | ||||
| 	pflag.BoolVar(&versionFlag, "version", false, "Show Task version.") | ||||
| 	pflag.BoolVarP(&helpFlag, "help", "h", false, "Shows Task usage.") | ||||
| 	pflag.BoolVarP(&init, "init", "i", false, "Creates a new Taskfile.yaml in the current folder.") | ||||
| 	pflag.BoolVarP(&init, "init", "i", false, "Creates a new Taskfile.yml in the current folder.") | ||||
| 	pflag.BoolVarP(&list, "list", "l", false, "Lists tasks with description of current Taskfile.") | ||||
| 	pflag.BoolVarP(&listAll, "list-all", "a", false, "Lists tasks with or without a description.") | ||||
| 	pflag.BoolVarP(&listJson, "json", "j", false, "Formats task list as JSON.") | ||||
|   | ||||
| @@ -56,7 +56,7 @@ _arguments \ | ||||
|     + '(operation)' \ | ||||
|         {-l,--list}'[list describable tasks]' \ | ||||
|         {-a,--list-all}'[list all tasks]' \ | ||||
|         {-i,--init}'[create new Taskfile.yaml]' \ | ||||
|         {-i,--init}'[create new Taskfile.yml]' \ | ||||
|         '(-*)'{-h,--help}'[show help]' \ | ||||
|         '(-*)--version[show version and exit]' \ | ||||
|         '*: :__task_list' | ||||
|   | ||||
| @@ -30,7 +30,7 @@ variable | ||||
| | `-f` | `--force` | `bool` | `false` | Forces execution even when the task is up-to-date. | | ||||
| | `-g` | `--global` | `bool` | `false` | Runs global Taskfile, from `$HOME/Taskfile.{yml,yaml}`. | | ||||
| | `-h` | `--help` | `bool` | `false` | Shows Task usage. | | ||||
| | `-i` | `--init` | `bool` | `false` | Creates a new Taskfile.yaml in the current folder. | | ||||
| | `-i` | `--init` | `bool` | `false` | Creates a new Taskfile.yml in the current folder. | | ||||
| | `-I` | `--interval` | `string` | `5s` | Sets a different watch interval when using `--watch`, the default being 5 seconds. This string should be a valid [Go Duration](https://pkg.go.dev/time#ParseDuration). | | ||||
| | `-l` | `--list` | `bool` | `false` | Lists tasks with description of current Taskfile. | | ||||
| | `-a` | `--list-all` | `bool` | `false` | Lists tasks with or without a description. | | ||||
|   | ||||
							
								
								
									
										6
									
								
								init.go
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								init.go
									
									
									
									
									
								
							| @@ -22,9 +22,11 @@ tasks: | ||||
|     silent: true | ||||
| ` | ||||
|  | ||||
| const defaultTaskfileName = "Taskfile.yml" | ||||
|  | ||||
| // InitTaskfile Taskfile creates a new Taskfile | ||||
| func InitTaskfile(w io.Writer, dir string) error { | ||||
| 	f := filepathext.SmartJoin(dir, "Taskfile.yaml") | ||||
| 	f := filepathext.SmartJoin(dir, defaultTaskfileName) | ||||
|  | ||||
| 	if _, err := os.Stat(f); err == nil { | ||||
| 		return ErrTaskfileAlreadyExists | ||||
| @@ -33,6 +35,6 @@ func InitTaskfile(w io.Writer, dir string) error { | ||||
| 	if err := os.WriteFile(f, []byte(defaultTaskfile), 0o644); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	fmt.Fprintf(w, "Taskfile.yaml created in the current directory\n") | ||||
| 	fmt.Fprintf(w, "%s created in the current directory\n", defaultTaskfile) | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
| @@ -704,11 +704,11 @@ func TestStatusVariables(t *testing.T) { | ||||
|  | ||||
| func TestInit(t *testing.T) { | ||||
| 	const dir = "testdata/init" | ||||
| 	var file = filepathext.SmartJoin(dir, "Taskfile.yaml") | ||||
| 	var file = filepathext.SmartJoin(dir, "Taskfile.yml") | ||||
|  | ||||
| 	_ = os.Remove(file) | ||||
| 	if _, err := os.Stat(file); err == nil { | ||||
| 		t.Errorf("Taskfile.yaml should not exist") | ||||
| 		t.Errorf("Taskfile.yml should not exist") | ||||
| 	} | ||||
|  | ||||
| 	if err := task.InitTaskfile(io.Discard, dir); err != nil { | ||||
| @@ -716,7 +716,7 @@ func TestInit(t *testing.T) { | ||||
| 	} | ||||
|  | ||||
| 	if _, err := os.Stat(file); err != nil { | ||||
| 		t.Errorf("Taskfile.yaml should exist") | ||||
| 		t.Errorf("Taskfile.yml should exist") | ||||
| 	} | ||||
| 	_ = os.Remove(file) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user