Skip to content

Commit

Permalink
fix(buildifier): formatting of BUILD file (#594)
Browse files Browse the repository at this point in the history
When editing a file named BUILD, the command `buildifier` was executed,
but the file in the editor was not reformatted properly.

If I'd run `buildifier [path-to-file]`, the file would be reformatted as
expected, so the formatter works as expected in this case.

After experimenting a bit, I came up with the new command line I propose
in this change. It still sends the code via stdin to `buildifier`, but
now is aware of the path the file has in the project. This seems to have
an influence on the behavior of `buildifier`.

See `buildifier --help`:

```
  -type string
        Input file type: build (for BUILD files), bzl (for .bzl files),
        workspace (for WORKSPACE files), default (for generic Starlark
        files) or auto (default, based on the filename) (default "auto")
```
  • Loading branch information
LarsMichelsen authored Dec 8, 2024
1 parent 02fd64f commit e76afe8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lua/conform/formatters/buildifier.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ return {
description = "buildifier is a tool for formatting bazel BUILD and .bzl files with a standard convention.",
},
command = "buildifier",
args = { "-path", "$FILENAME", "-" },
}

0 comments on commit e76afe8

Please sign in to comment.