Skip to content

Commit

Permalink
feat: add an example of 'before'
Browse files Browse the repository at this point in the history
Signed-off-by: Brian McGee <[email protected]>
  • Loading branch information
brianmcgee committed Feb 15, 2024
1 parent f4700c4 commit 2b49923
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
14 changes: 7 additions & 7 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ func TestReadConfigFile(t *testing.T) {
as.Equal([]string{"*.hs"}, haskell.Includes)
as.Equal([]string{"examples/haskell/"}, haskell.Excludes)

// nix
nix, ok := cfg.Formatters["nix"]
as.True(ok, "nix formatter not found")
as.Equal("alejandra", nix.Command)
as.Nil(nix.Options)
as.Equal([]string{"*.nix"}, nix.Includes)
as.Equal([]string{"examples/nix/sources.nix"}, nix.Excludes)
// alejandra
alejandra, ok := cfg.Formatters["alejandra"]
as.True(ok, "alejandra formatter not found")
as.Equal("alejandra", alejandra.Command)
as.Nil(alejandra.Options)
as.Equal([]string{"*.nix"}, alejandra.Includes)
as.Equal([]string{"examples/nix/sources.nix"}, alejandra.Excludes)

// ruby
ruby, ok := cfg.Formatters["ruby"]
Expand Down
2 changes: 2 additions & 0 deletions nix/formatters.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ with pkgs; [
rustfmt
shellcheck
shfmt
statix
deadnix
terraform
]
8 changes: 7 additions & 1 deletion test/examples/treefmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ options = [
includes = ["*.hs"]
excludes = ["examples/haskell/"]

[formatter.nix]
[formatter.alejandra]
command = "alejandra"
includes = ["*.nix"]
# Act as an example on how to exclude specific files
excludes = ["examples/nix/sources.nix"]
# Make this run before deadnix
# Note this formatter determines the file set for any 'downstream' formatters
before = "deadnix"

[formatter.deadnix]
command = "deadnix"

[formatter.ruby]
command = "rufo"
Expand Down

0 comments on commit 2b49923

Please sign in to comment.