Skip to content

Commit 2b49923

Browse files
committed
feat: add an example of 'before'
Signed-off-by: Brian McGee <[email protected]>
1 parent f4700c4 commit 2b49923

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

config/config_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ func TestReadConfigFile(t *testing.T) {
5252
as.Equal([]string{"*.hs"}, haskell.Includes)
5353
as.Equal([]string{"examples/haskell/"}, haskell.Excludes)
5454

55-
// nix
56-
nix, ok := cfg.Formatters["nix"]
57-
as.True(ok, "nix formatter not found")
58-
as.Equal("alejandra", nix.Command)
59-
as.Nil(nix.Options)
60-
as.Equal([]string{"*.nix"}, nix.Includes)
61-
as.Equal([]string{"examples/nix/sources.nix"}, nix.Excludes)
55+
// alejandra
56+
alejandra, ok := cfg.Formatters["alejandra"]
57+
as.True(ok, "alejandra formatter not found")
58+
as.Equal("alejandra", alejandra.Command)
59+
as.Nil(alejandra.Options)
60+
as.Equal([]string{"*.nix"}, alejandra.Includes)
61+
as.Equal([]string{"examples/nix/sources.nix"}, alejandra.Excludes)
6262

6363
// ruby
6464
ruby, ok := cfg.Formatters["ruby"]

nix/formatters.nix

+2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ with pkgs; [
1212
rustfmt
1313
shellcheck
1414
shfmt
15+
statix
16+
deadnix
1517
terraform
1618
]

test/examples/treefmt.toml

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ options = [
2626
includes = ["*.hs"]
2727
excludes = ["examples/haskell/"]
2828

29-
[formatter.nix]
29+
[formatter.alejandra]
3030
command = "alejandra"
3131
includes = ["*.nix"]
3232
# Act as an example on how to exclude specific files
3333
excludes = ["examples/nix/sources.nix"]
34+
# Make this run before deadnix
35+
# Note this formatter determines the file set for any 'downstream' formatters
36+
before = "deadnix"
37+
38+
[formatter.deadnix]
39+
command = "deadnix"
3440

3541
[formatter.ruby]
3642
command = "rufo"

0 commit comments

Comments
 (0)