mirror of
https://github.com/dense-analysis/ale
synced 2025-01-25 01:02:50 +00:00
eb0ebe6221
Buildifier offers a -path command line option: > Buildifier's reformatting depends in part on the path to the file > relative to the workspace directory. Normally buildifier deduces > that path from the file names given, but the path can be given > explicitly with the -path argument. This is especially useful when > reformatting standard input, or in scripts that reformat a temporary > copy of a file. This lets us drop our `-type`-guessing logic. For the moment, we rely on the buffer filename being "relative to the workspace directory", which it generally is, but in a future change, we should introduce logic that will locate the WORKSPACE file and adjusts the filename relative to that directory. This could be complicated based on the working directory in which `buildifier` is executed, so a little more research is necessary to implement that logic correctly.
30 lines
932 B
Plaintext
30 lines
932 B
Plaintext
Before:
|
|
let g:ale_bazel_buildifier_options = ''
|
|
call ale#assert#SetUpFixerTest('bzl', 'buildifier')
|
|
|
|
After:
|
|
call ale#assert#TearDownFixerTest()
|
|
|
|
Execute(The buildifier callback should return the correct default values):
|
|
call ale#test#SetFilename('../test-files/bazel/WORKSPACE')
|
|
|
|
AssertFixer
|
|
\ {
|
|
\ 'command': ale#Escape(g:ale_bazel_buildifier_executable)
|
|
\ . ' -mode fix -lint fix -path '
|
|
\ . ale#Escape(ale#test#GetFilename('../test-files/bazel/WORKSPACE'))
|
|
\ . ' -'
|
|
\ }
|
|
|
|
Execute(The buildifier callback should include any additional options):
|
|
call ale#test#SetFilename('../test-files/bazel/WORKSPACE')
|
|
let g:ale_bazel_buildifier_options = '--some-option'
|
|
|
|
AssertFixer
|
|
\ {
|
|
\ 'command': ale#Escape(g:ale_bazel_buildifier_executable)
|
|
\ . ' -mode fix -lint fix -path '
|
|
\ . ale#Escape(ale#test#GetFilename('../test-files/bazel/WORKSPACE'))
|
|
\ . ' --some-option -'
|
|
\ }
|