ashfurrow / danger-ruby-swiftlint

A Danger plugin for SwiftLint.
https://rubygems.org/gems/danger-swiftlint
MIT License
203 stars 80 forks source link

The current directory changes for the entire process after calling this plugin #157

Closed revolter closed 3 years ago

revolter commented 3 years ago

Currently, if you're using the directory option, after calling a lint method on this plugin, the current directory remains changed to the specified value, even for other plugins.

It is caused by this line:

https://github.com/ashfurrow/danger-ruby-swiftlint/blob/d1ac19bbe5a518b7bd5f343aeea84c5df6e2e2c3/ext/swiftlint/swiftlint.rb#L12

A workaround for this is:

current_dir = Dir.pwd()

swiftlint.directory = 'MyDirectory'
swiftlint.lint_files

Dir.chdir(current_dir)

(Moved from https://github.com/ashfurrow/danger-swiftlint/issues/4)