Closed alexanderwe closed 2 years ago
Hi! Thanks for the detailed question. I agree that if which swiftlint
yields the string /opt/homebrew/bin/swiftlint
then this should work. Could you add some logging here so we could learn more?
binary_path = %x( which swiftlint )
puts "binary_path: #{binary_path}"
swiftlint.config_file = './.swiftlint.yml'
swiftlint.binary_path = binary_path
swiftlint.lint_files
When I just tested how %x( )
works in irb
and got a string with \n
at the end:
2.6.6 :001 > %x( which yarn )
=> "/usr/local/bin/yarn\n" # I'm on an unusual machine without SwiftLint installed right now 😅
So maybe adding a .strip
would fix this?
swiftlint.config_file = './.swiftlint.yml'
swiftlint.binary_path = %x( which swiftlint ).strip
swiftlint.lint_files
Let us know how it goes!
Hey @ashfurrow - thanks for the fast reply.
At first, your suggestion with .strip
works, so thanks a lot! 👍 Danger now picks up the correct path locally AND on the CI.
But what's interesting though, when I add logging I do not see the \n
at the end, but still .strip
did the trick and it works now
You used `puts` in your Dangerfile. To print out text to GitHub use `message` instead
binary_path: /opt/homebrew/bin/swiftlint
[!] The exception involves the following plugins:
- danger-swiftlint
Ah, right 😅
Yeah I'm not sure about formatting the \n
newline. puts
doesn't seem distinguish the two, but irb
does:
2.6.0 :001 > "Hello, world\n"
=> "Hello, world\n"
2.6.0 :002 > "Hello, world"
=> "Hello, world"
2.6.0 :003 > puts "Hello, world\n"
Hello, world
=> nil
2.6.0 :004 > puts "Hello, world"
Hello, world
=> nil
2.6.0 :005 >
🤷 I'm glad it's working, though!
Hey,
I am currently trying to let
danger-ruby-swiftlint
use a dynamic binary path by configuring it like the following:But it seems this is not working, I always get an error message that SwiftLint is not installed. But when I directly use the value calculated by
%x( which swiftlint )
it is workingThe reason why I am doing this is two fold:
danger-ruby-swiftlint
Do you maybe have an idea what I am doing wrong or if there is another way to make it possible what I try to achieve ?
Thanks in advance - and thanks a lot of course for maintaining this library ! :)