discourse/Dangerfile

30 lines
816 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

require 'json'
if git.lines_of_code > 500
warn("This PR seems big, we prefer smaller PR. Please be sure this is needed and cant be split in smaller commits.")
end
rubocop_output = `bundle exec rubocop --parallel`
if !rubocop_output.empty?
offenses = JSON.parse(rubocop_output)['files']
.select { |f| f['offenses'].any? }
fail(%{
This PR has multiple rubocop offenses:
#{offenses.join("\n")}
})
end
prettier_output = `prettier --list-different "app/assets/stylesheets/**/*.scss" "app/assets/javascripts/**/*.es6" "test/javascripts/**/*.es6" "plugins/**/*.scss" "plugins/**/*.es6"`
if !prettier_output.empty?
offenses = JSON.parse(prettier_output)['files']
.select { |f| f['offenses'].any? }
fail(%{
This PR has multiple prettier offenses:
#{offenses.join("\n")}
})
end