Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions bin/statelint
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@ require 'statelint'
linter = StateMachineLint::Linter.new

# arguments are JSON filenames
ARGV.each do |file|
problems = linter.validate(ARGV[0])

if !problems.empty?
header = (problems.size == 1) ? 'One error:' : "#{problems.size} errors:"
puts header
problems.each do |problem|
puts " #{problem}"
end

exit 1
end
linted_files = ARGV.map { |file|
[file, linter.validate(file)]
}.to_h

problem_count = linted_files.values.flatten.compact.count

exit if problem_count <= 0

linted_files.each do |file, problems|
problem_size = problems.size

next if problem_size <= 0

header = problem_size == 1 ? 'One error' : "#{problem_size} errors"
puts header + ": for #{file}"
puts " #{problems.join("\n ")}"
end

exit 1