Skip to content

Commit

Permalink
Add shell formatting tasks / workspace settings
Browse files Browse the repository at this point in the history
  • Loading branch information
chokoswitch committed Jun 12, 2024
1 parent be261ad commit 6cbec7a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ format and lint tasks target the following languages:

- Go
- Markdown
- Shell-like, including Dockerfile (files supported by [mvdan-sh](https://github.com/mvdan/sh))
- YAML

All supporting tasks are executed with `go run` - this means that all languages
Expand Down
18 changes: 17 additions & 1 deletion go-build.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@
}
],
"extensions": {
"recommendations": ["esbenp.prettier-vscode"]
"recommendations": ["esbenp.prettier-vscode", "foxundermoon.shell-format"]
},
"settings": {
"editor.tabSize": 2,
"[dockerfile]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[dotenv]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[ignore]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[github-actions-workflow]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
Expand All @@ -24,6 +36,10 @@
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[shellscript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[yaml]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
Expand Down
22 changes: 22 additions & 0 deletions standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,28 @@ func DefineTasks(opts ...Option) {
}))
}

if !conf.excluded("format-shell") {
RegisterFormatTask(goyek.Define(goyek.Task{
Name: "format-shell",
Usage: "Formats shell-like code, including Dockerfile, ignore, dotenv.",
Parallel: true,
Action: func(a *goyek.A) {
cmd.Exec(a, fmt.Sprintf("go run github.com/wasilibs/go-prettier/cmd/prettier@%s --no-error-on-unmatched-pattern --write '**/*.sh' '**/*.bash' '**/Dockerfile' '**/*.dockerfile' '**/.*ignore' '**/.env*'", verGoPrettier))
},
}))
}

if !conf.excluded("lint-shell") {
RegisterLintTask(goyek.Define(goyek.Task{
Name: "lint-shell",
Usage: "Lints shell-like code, including Dockerfile, ignore, dotenv.",
Parallel: true,
Action: func(a *goyek.A) {
cmd.Exec(a, fmt.Sprintf("go run github.com/wasilibs/go-prettier/cmd/prettier@%s --no-error-on-unmatched-pattern --check '**/*.sh' '**/*.bash' '**/Dockerfile' '**/*.dockerfile' '**/.*ignore' '**/.env*'", verGoPrettier))
},
}))
}

if !conf.excluded("format-yaml") {
RegisterFormatTask(goyek.Define(goyek.Task{
Name: "format-yaml",
Expand Down
2 changes: 1 addition & 1 deletion versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package build

const (
verGolangCILint = "v1.58.1"
verGoPrettier = "79c5c1b6332968320c44f93a6a367c54b31796d3"
verGoPrettier = "16a91d6604f1e9fa12ffd31e04e1eb6a28ad5afb"
verGoYamllint = "v1.35.1"
)

0 comments on commit 6cbec7a

Please sign in to comment.