File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 1
1
# Example generated by ../examples.sh
2
2
[formatter .sql-formatter ]
3
- command = " sql-formatter"
3
+ command = " sql-formatter-fix "
4
4
excludes = []
5
5
includes = [" *.sql" ]
6
- options = [" --fix " ]
6
+ options = []
Original file line number Diff line number Diff line change 1
1
{
2
+ pkgs ,
2
3
lib ,
3
4
config ,
4
5
mkFormatterModule ,
34
35
( mkFormatterModule {
35
36
name = "sql-formatter" ;
36
37
package = "sql-formatter" ;
37
- args = [
38
- "--fix"
39
- ] ;
40
38
includes = [ "*.sql" ] ;
41
39
} )
42
40
] ;
52
50
53
51
config = lib . mkIf cfg . enable {
54
52
settings . formatter . sql-formatter = {
55
- command = "${ cfg . package } /bin/sql-formatter" ;
56
- options = lib . optionals ( cfg . dialect != null ) [
57
- "-l=${ cfg . dialect } "
58
- ] ;
53
+ # sql-formatter doesn't support multiple file targets
54
+ # see https://github.com/sql-formatter-org/sql-formatter/issues/552
55
+ command = pkgs . writeShellScriptBin "sql-formatter-fix" ''
56
+ for file in "$@"; do
57
+ ${ cfg . package } /bin/sql-formatter --fix ${
58
+ lib . optionalString ( cfg . dialect != null ) "-l ${ cfg . dialect } "
59
+ } $file
60
+ done
61
+ '' ;
59
62
} ;
60
63
} ;
61
64
}
You can’t perform that action at this time.
0 commit comments