lib/ormolu/plugin.rb in danger-ormolu-0.0.2 vs lib/ormolu/plugin.rb in danger-ormolu-0.0.3

- old
+ new

@@ -13,27 +13,27 @@ class DangerOrmolu < Plugin # Check that the files are correctly formatted # @param files [Array<String>] # @return [void] # - def check(files) + def check(files, path: 'ormolu', level: :warn) files .each do |file| - result = `ormolu --mode stdout --check-idempotence "#{file}" | diff "#{file}" -` + result = `#{path} --mode stdout --check-idempotence "#{file}" | diff "#{file}" -` next if result.empty? extract_diffs(result.lines) .each do |diff| - inconsistence(file, diff[:line], diff[:diff]) + inconsistence(file, diff[:line], diff[:diff], level) end end end private - def inconsistence(file, line, diff) + def inconsistence(file, line, diff, level) message = "Style error, fix it through \n\n```haskell\n#{diff.join}\n``` \n" - warn(message, file: file, line: line) + send level, message, file: file, line: line end def extract_diffs(lines) lines .reverse