buildifier-prebuilt
buildifier-prebuilt copied to clipboard
Add shell helper to make it easier to execute `buildozer` commands on a repository
The current README.md states that the following should work:
bazel run -- @buildifier_prebuilt//:buildozer ARGS
However, this will not work correctly. Bazel will execute the command in a sandbox, not the workspace. Hence, buildozer
will never find any of the paths.
A possible fix would be to provide a shell script that performs a cd "${BUILD_WORKSPACE_DIRECTORY}"
and then executes the buildozer
commands.
NOTE: The buildifier
would also benefit from this technique as today one must specify absolute paths for buildifier
to find files and directories.
Ah yea, the only reason I didn't do a shell script before was because that seemed unnecessary, but yea this is a good reason
BTW a shell wrapper is not needed at all:
alias(
name = "buildozer",
actual = "@buildifier_prebuilt//:buildozer",
)
Then here is an example execution:
$ bazel run :buildozer -- 'print actual' //:buildozer
INFO: Invocation ID: 3f4494b3-882e-4c28-a33f-2e37ccb33baa
INFO: Analyzed target //:buildozer (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target @buildifier_prebuilt~6.0.0.1//buildozer:buildozer up-to-date:
dist/bin/external/buildifier_prebuilt~6.0.0.1/buildozer/buildozer
INFO: Elapsed time: 0.192s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: dist/bin/external/buildifier_prebuilt~6.0.0.1/buildozer/buildozer 'print actual' //:buildozer
@buildifier_prebuilt//:buildozer