Skip to content

Instantly share code, notes, and snippets.

@ykpythemind
Created December 11, 2019 14:12
Show Gist options
  • Save ykpythemind/c1b84eed4794be94d016a3f2ebb1522b to your computer and use it in GitHub Desktop.
Save ykpythemind/c1b84eed4794be94d016a3f2ebb1522b to your computer and use it in GitHub Desktop.
slimファイル中のRubyのSyntaxErrorのみ検証するrake task
# CIで実行されない行があると死んだりするので、それの検証用
desc 'slim_lintを用いてslimファイル中のRubyのSyntaxErrorのみ検証する'
task slim_lint_syntax: :environment do
result = `bundle exec slim-lint app/views/`
if $?.exitstatus != 0 && $?.exitstatus != 65 # rubocop:disable Style/SpecialGlobalVars
# https://github.com/sds/slim-lint/blob/79f388a3a3c2ee43ed8cdbaf63fb56038498370c/lib/slim_lint/cli.rb#L86
abort "slim_lint failed. #{result}"
end
syntax_error_lines = result.each_line.select do |line|
line.include? 'RuboCop: Lint/Syntax'
end
unless syntax_error_lines.empty?
puts 'Syntax Error detected.'
puts syntax_error_lines.join("\n")
abort
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment